Yep. Sorry for the terminology confusion, I use Constructor (what they call
them in Haskell) and tag interchangeably, I probably shouldn't.
So, when you do
"type Foo = Bar ... | Baz ..."
You get a tag. The tag can be used to construct Foos, as a function, or to
destruct them, in a "case ... of " expression.
When you do
"type alias Rec = {x : ..., y : ..., ...}"
where the type on the right is a record, then you can use Rec as a
shorthand for (\x y ... -> {x : x, y : y, ...}), that is, it takes the
arguments in the order you specified fields in the type alias. But, I guess
you can't pattern match on things using this syntactic sugar.
It is still possible to pattern match on a record, you can see how to do
that here: http://elm-lang.org/docs/syntax#records
On Sun, Jan 29, 2017 at 3:58 PM, jadski <[email protected]> wrote:
> That suggests either the compiler distinguishes between implicit &
> explicit declarations, or constructors and tags are treated differently (my
> money's on the latter).
>
> On Sunday, 29 January 2017 23:25:25 UTC, Joey Eremondi wrote:
>>
>> This is certainly a case where the message could be better, perhaps we
>> should log it at https://github.com/elm-lang/error-message-catalog if
>> something similar is not already there.
>>
>> Types and expressions (including Constructors) are in different
>> namespaces. So while there is a Type named Response, there's no Constructor
>> named Response, which is what the compiler is looking for in the pattern
>> match.
>>
>> What's confusing (to me) is that, when you do "type alias Foo = {field1,
>> field2...}", usually it generates a fake pseudo-constructor that lets you
>> make a record without naming fields, i.e. as "Foo x y...". But I guess
>> you're not allowed to pattern match with it?
>>
>> On Sun, Jan 29, 2017 at 3:08 PM, jadski <[email protected]> wrote:
>>
>>> Though I still don't understand why the compiler says Http does not
>>> expose Response - that contradicts the code?
>>>
>>> --
>>> 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.
>>>
>>
>> --
> 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.
>
--
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.