I always figured we'd use plain old functions that take some of the fields and add the others from there.
I know that records are Elm's replacement for Haskell's type classes, and according to the blog records can achieve almost everything type classes can. Haskell's type classes let you add default implementations that all instances will automatically pick up. Based on a quick search in this group, it appears this feature is missing from Elm. There are some interesting ideas proposed (https://groups.google.com/forum/#!searchin/elm-discuss/records$20optional/elm-discuss/gvmNskIhWKw/QOYlLr9lbUEJ); has any work on this been done? If not, has anyone found a way to use records in such a way that you don't have to provide a value for every property? An obvious way would be to make optional properties Maybe or have an Optional type, but that would still require setting every property in order to build a type, which is what I'm trying to avoid.Thanks!
--
You received this message because you are subscribed to the Google Groups "Elm Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elm-discuss...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Evan, the idea is that typeclasses in Haskell are related to explicit record passing in Elm. Typeclasses in Haskell allow default implementation. Joe is looking for something of that power for Elm records. This isn't about typeclass functionality per se, it's about wanting something Haskell typeclasses happen to have.
Why not create a default version?type alias RenderOptions ={ container: Box, title: String, background: String, attributes: List Html.Attribute}-- I don't know what a "Box" is so I used a ? that you can fill indefaultRenderOptions ={ container = ?, title = "Dummy Title", background = ?, attributes = []}myOptions ={ defualtRenderOptions |title <- "My Thing"}
--