On Wed, May 3, 2017 at 6:56 AM, Joey Eremondi <[email protected]>
wrote:

> The problem is, this would only work when all the constructors had 0
> arguments , or arguments of the same type. Otherwise, what would the type
> of such a list be?
>

But if we would have a function like:

defaultValues : Type a -> List a

where Type a would be some compiler magic value that contains the type info
of a, wouldn't we be able to say

type WeekDay = Mon | Tue | Wed | Thu | Fri | Sat | Sun

allDays = defaultValues WeekDay

defaultValues would return a list of all the default values for all the
constructors. So, if the constructor takes 0 parameters would return the
tag, if it takes 1 value would return the value created by applying the tag
to the default value of the type it contains (eg `Some Int` would return `Some
0`). The default value for a type can be by convention the first tag for
tagged unions. For the number it would be 0 and for String "".




-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
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.

Reply via email to