Re: [elm-discuss] Guidance for using "type alias" vs. single-constructor union types

2017-01-23 Thread Bob Hutchison
> On Jan 16, 2017, at 10:10 AM, art yerkes wrote: > > You could try elm-generic-dict to have arbitrary keys in dicts. Thank you! I didn’t know about this. This will remove a ton of cruft and ugly code from my code base. I use single-constructor ADTs all over the place, and they always seem to

[elm-discuss] Guidance for using "type alias" vs. single-constructor union types

2017-01-16 Thread Ian Mackenzie
I agree with the point about adding helper functions for your data type so you can treat it as opaque in most places. For the rest, though, you can also use the slightly obscure 'as' syntax 'foo ((Foo s) as f) = ...' which allows you to use both 's' and 'f' in your function body (with the additi

[elm-discuss] Guidance for using "type alias" vs. single-constructor union types

2017-01-16 Thread Austin Bingham
I recently had to chase down a bug where I was calling a function with the arguments in the wrong order. The function's declared argument types were each an alias for string, so the compiler happily let me swap them. In order to avoid this in the future, I'm experimenting with using single-cons