The function String -> a is called eval, and it's not coming to Elm because it would break all kinds of type guarantees. You can implement functions from String to a specific concrete type, although that type will have to have some notion of failure or emptiness if it's not wrapped in a Maybe or a Result. Nick gives you an example of how to do that; more simply you can just do a case analysis of all the strings you want (or if statements with regexes...).
But if at all possible, don't use string identifiers at all. Sometimes it can't be helped (usually JS of JSON interop) but especially if all your union type's tags are not functions, just pass those around within Elm. -- 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 [email protected]. For more options, visit https://groups.google.com/d/optout.
