Holmusk / elm-street

:deciduous_tree: Crossing the road between Haskell and Elm
Mozilla Public License 2.0
88 stars 6 forks source link

Support List.NonEmpty representation in Elm #105

Closed turboMaCk closed 2 years ago

turboMaCk commented 4 years ago

This is proof of concept implementation for the https://github.com/Holmusk/elm-street/issues/102.

Usage on Elm Side.

One can easily convert pair to any custom implementation of NonEmpty:

type Cons a = Cons a (List a)

uncurry : (a -> b -> c) -> (a, b) -> c
uncurry f (a, b) = f a b

decodeConsInt : Decoder (Cons Int)
decodeConsInt = Decode.map (uncurry Cons) Decoder.generatedDecoder

In most case it should be simpler to use already compatible implementation -- That will especially simplify cases where NonEmpty is nested within other data.

googleson78 commented 4 years ago

You could add a reference to your recommended library in the readme, perhaps (?)

turboMaCk commented 4 years ago

@googleson78 definitely. Documentation is something I did not look into yet at all but we definitely should review it before considering this or any other implementation complete.

turboMaCk commented 2 years ago

I'll hold merge of this just for a bit because I also have one other suggestion which is related to this I would like to know your opinion about before merging this PR

turboMaCk commented 2 years ago

ok lets go with this first. Other changes will require some discussions as well.