This is awesome stuff, @selbekk
! Really well written :)
I just thought I'd add a small note regarding type vs type alias.
A type alias is just that, an alias. The actual type is what comes after =.
That means that everywhere you use Model in type signatures, you could actually use the record type { todos: List Todo ... } instead and it would look the same to the compiler. You're essentially just giving a type another name.
type on the other hand actually creates a new type. So...
typeMoney=MoneyIntsum:Moneysum=Money5typeCelsius=CelsiusInttemp:Celsiustemp=Celsius5-- Celsius /= Money-- sum /= temptypealiasMoney=Intsum:Moneysum=5typealiasCelsius=Inttemp:Celsiustemp=5-- Celsius == Money == Int-- sum == temp
When it comes to use. Type aliases are often used to shorten types or make them more readable. Records is one example of this, but also:
typePerson=PersonFirstNameLastNametypealiasFirstName=StringtypealiasLastName=String-- Is more readable than, but also the equivalent of...typePerson=PersonStringString
Ah, that's a really nice way to show the difference between the two! Thanks a ton for taking the time to clarify this - and thanks for all the great work you do with the Elm language.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
This is awesome stuff, @selbekk ! Really well written :)
I just thought I'd add a small note regarding type vs type alias.
A type alias is just that, an alias. The actual type is what comes after
=
.That means that everywhere you use
Model
in type signatures, you could actually use the record type{ todos: List Todo ... }
instead and it would look the same to the compiler. You're essentially just giving a type another name.type
on the other hand actually creates a new type. So...When it comes to use. Type aliases are often used to shorten types or make them more readable. Records is one example of this, but also:
Ah, that's a really nice way to show the difference between the two! Thanks a ton for taking the time to clarify this - and thanks for all the great work you do with the Elm language.