[elm-discuss] Re: Is there any way to use a type instead of a string for the value of an option

2016-11-01 Thread James Hamilton
You're right it is easy, but it also feels quite messy. I appreciate your point that the specific use-case of value is to represent a value attribute in HTML which is a string, but part of the fun of elm is that it hides a lot of implementation details in HTML and CSS, and given that you can

[elm-discuss] Re: Is there any way to use a type instead of a string for the value of an option

2016-10-27 Thread Martin Cerny
I think it does not necessarily involve any extensions to the language, it could be only syntactic sugar. You may want the programmer to explicitly opt in with a syntax like: enum type _NAME_ = _OPT_1_ | _OPT_2_ | _OPT_N_ , enumerator = _ENUMERATOR_NAME_ which would

[elm-discuss] Re: Is there any way to use a type instead of a string for the value of an option

2016-10-26 Thread OvermindDL1
That sounds like a typeclass or a HPT, neither of which are in Elm (yet?). Passing in manual serialization/deserialization functions is easy to do though. :-) On Wednesday, October 26, 2016 at 10:32:18 AM UTC-6, Martin Cerny wrote: > > I think this points to a more general use case. I think

[elm-discuss] Re: Is there any way to use a type instead of a string for the value of an option

2016-10-26 Thread Martin Cerny
I think this points to a more general use case. I think it would be useful to be able to use union types a bit like enums in other languages (my background is mostly Java). For example having type Role = Admin | Moderator | User it would be cool to get something like: Role.optionNames ==

[elm-discuss] Re: Is there any way to use a type instead of a string for the value of an option

2016-10-25 Thread Ian Mackenzie
I've been slowly working on a small library to make working with the basic input widgets like more pleasant to work with - I'd be interested to see what you think. The implementation

[elm-discuss] Re: Is there any way to use a type instead of a string for the value of an option

2016-10-25 Thread OvermindDL1
`option` is supposed to match to the html , thus only strings, any marshalling you will need to perform yourself, such as by, for example, wrapping up option into something like `optionMyType t = option [ value (myTypeSerialize t) ]` or so for ease of use. :-) On Tuesday, October 25, 2016 at