When should one use *type *and when should one use *type alias*? Why not 
use *type* everywhere?

On Friday, December 18, 2015 at 1:16:11 PM UTC-8, Joey Eremondi wrote:
>
> They have similar names because they are performing similar operations: 
> they're both ways to give a name to a type.
>
> There was a lot of debate over which naming to use. 
>
> One of the lines of thought was that "type" is the only way in Elm to 
> *create* a new type. So while it behaves like an enum, it is named *type* 
> to show that you are creating a new type, which is its own entity in the 
> typechecker.
>
> Type alias isn't creating a distinct type, it is literally just giving a 
> name to an existing type. A type alias will save you keystrokes, but do 
> nothing more.
>
> So you're pretty close when you say it's giving a name to a type 
> definition. What would be more accurate is to say that "type" defines and 
> names a new type (which behaves like an enum with data attached), and "type 
> alias" gives a name to an existing type.
>
> The idea is that Enums are something from C++/Java/Rust, which we don't 
> want people to need to know about to use Elm. We wanted to name it to be 
> descriptive and self-contained, not assuming anything about the 
> programmer's background in other languages, particularly because they are 
> quite different, having data attached. They're kind of like Enum and Struct 
> combined.
>
> On Fri, Dec 18, 2015 at 1:08 PM, Don Barthel <[email protected] 
> <javascript:>> wrote:
>
>> Please correct me if I am wrong but I am having a mental block on the 
>> relationship between 'type' and 'type alias'. They must be related because 
>> the have nearly the same name.
>>
>> 'type' is an enum (and never anything else), possibly with data 
>> associated with each enum constant (as a "tagged union").
>>
>> 'type alias' is a way to give a name to a type definition.
>>
>> They seems like quite different things. Why are they named so similarly? 
>> "type alias" sounds like a type of "type.
>>
>>
>> -- 
>> 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] <javascript:>.
>> 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.

Reply via email to