Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor for better composability with custom types in sites #30

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

cdfa
Copy link

@cdfa cdfa commented Jan 31, 2023

Based on #29, so that needs to be merged first.
When all review comments are fixed, we should add a commit to bump the package version.

@cdfa cdfa requested a review from M-Skipemski January 31, 2023 17:08
, fromJsonWithEdges
, fromJsonWithoutEdges
, categoryListFromJson
, CategoryList, ResourceDataConstructor, depictionsOfClass, edgeFromJson, firstDepictionOfClass, resourceDataPipeline
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Formatting lijkt wat raar hier

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed!



# Access data

@docs getCategory
@docs getCategories
@docs getDepiction
@docs getDepictions
@docs firstDepictionOfClass
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Misschien toch mediaclass noemen ipv van class? Ik denk bij class aan een HTML class. Wel een goede rename verder.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mee eens. Fixed!


So you'll see this used in function signatures like:
type alias Resource =
SiteData (ResourceData Edges)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ik raakte een beetje in de war omdat zowel ResourceData en SiteData extensible records zijn. Is ResourceData alleen extensible omdat er evt edges in kunnen zitten? Zouden we dan niet gewoon een maybe (of andere type) kunnen gebruiken?

edit: ah wacht dat staat erboven, zodat we compile time weten weten of er edges zijn. Zit ook wel weer wat in

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inderdaad, met een Maybe weet je het niet at compile time. Weet niet helemaal zeker hoe vaak we dat echt gebruiken, maar aangezien het eerst ook zo was heb ik het maar behouden.

, publicationDate : Maybe Time.Posix
, media : Media
, blocks : List Block
, properties : Decode.Value
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Waarom heb je gekozen om properties op ginger niveau te houden?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ik had ze eerst weggehaald, maar toen kwam ik in de knoop met de functies in Ginger.Resource.Extra. In principe zouden we wel aparte types moeten maken voor de verschillende soorten resources (zoals een Event), zodat we de properties die bijvoorbeeld bij een event horen bij het decoden al eruit halen, maar het probleem is dat je ze dan na het decoden kwijt bent. Dan moet je in de Cache module van de website extra dictionaries gaan maken voor die specifieke resources, want anders kan je een Event niet meer heropbouwen uit de cache.

Je zou hetzelfde probleem met blocks hebben, maar omdat die volgens mij wel door de hele site hetzelfde is kunnen we gewoon het bestaande dictionary in de cache aanpassen en hoeven we geen extra dictionaries toe te voegen.

@@ -53,7 +52,7 @@ import Time

{-| -}
type Status
= Authenticated Identity (Maybe (ResourceWith Edges))
= Authenticated Identity (Maybe Decode.Value)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Waarom heb je hier gekozen omdat decode.value mee te geven ipv een type parameter van resource?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ik dacht eigenlijk dat het te veel impact zou hebben om daar een type variabele aan toe te voegen, maar nu ik er nog een keer naar kijk valt het eigenlijk wel mee. Ik was eerder aan de Data.Status aan het denken die ook door Fetch gebruikt wordt denk ik.

Zal ik er dan maar een type parameter van maken?

@cdfa
Copy link
Author

cdfa commented Feb 3, 2023

Misschien is het trouwens wel een goed idee om eerst uit te proberen hoe het is om mod_equilar hierop aan te passen voordat we het mergen, voor het geval we nog problemen tegen komen.
Ik heb deze elm.json om met lokale changes van elm-ginger te spelen:

Details

{
"type": "application",
"source-directories": [
"src",
"../../../../../../elm-ginger/src"
],
"elm-version": "0.19.1",
"dependencies": {
"direct": {
"NoRedInk/elm-json-decode-pipeline": "1.0.0",
"elm/browser": "1.0.2",
"elm/core": "1.0.5",
"elm/html": "1.0.0",
"elm/http": "2.0.0",
"elm/json": "1.1.3",
"elm/svg": "1.0.1",
"elm/time": "1.0.0",
"elm/url": "1.0.0",
"elm/file": "1.0.5",
"lukewestby/elm-string-interpolate": "1.0.4",
"mdgriffith/elm-animator": "1.1.1",
"joneshf/elm-tagged": "2.1.1",
"hecrj/html-parser": "2.3.4",
"elm/parser": "1.1.0",
"rtfeldman/elm-iso8601-date-strings": "1.1.4"
},
"indirect": {
"avh4/elm-color": "1.0.0",
"elm/bytes": "1.0.8",
"elm/regex": "1.0.0",
"elm/virtual-dom": "1.0.2",
"ianmackenzie/elm-units": "2.7.0",
"rtfeldman/elm-hex": "1.0.0"
}
},
"test-dependencies": {
"direct": {
"elm-explorations/test": "1.2.2"
},
"indirect": {
"elm/random": "1.0.0"
}
}
}

Voordat het werkt moet je misschien wel even je elm-stuff directory weggooien.

@cdfa cdfa requested a review from M-Skipemski February 6, 2023 11:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants