Thank you. Thanks is helpful. It seems a little odd that you can't declare
a strong type without tagging it with a name, but I'm too new to the
language to understand the rationale for this decision, and I'll move
forward with the assumption that this decision was made for a good reason.
Specifically, it feels like I should be able to say:
type Foo = { bar : String }
That said, I do understand what union types are, so this is good enough for
me to move forward with exploring the language. I appreciate the help.
On Friday, January 6, 2017 at 6:21:18 PM UTC-5, Wouter In t Velt wrote:
>
> My guess is that this has to do with the strange way in which your "Foo" -
> like in any record type alias -
>
> *Foo is at the same time a Type as well as constructor*.
>
> So Foo is a type, that you can use in type annotations and signatures, but
> also a function with the signature "String -> Foo", taking a String, and
> returning a type Foo.
>
> If you want to get another the constructor variant of "Foo", you can do
> this:
>
> derp = Foo
>
>
> If Foo were a strong type, like this:
>
> type Foo = FooConstructor { bar : String }
>
> then you could do
>
> type alias Derp = Foo
>
> and
>
> FooConstructor "bar"
>
>
> but you could* not* do
>
> type alias Derp = FooConstructor
>
> nor
>
> Foo "bar"
> Derp "herp"
>
>
> Hope this makes some sense..
>
--
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.