Normally, when you alias a record, Elm creates a “record constructor" automatically. See this note at the bottom of http://guide.elm-lang.org/types/type_aliases.html <http://guide.elm-lang.org/types/type_aliases.html>:
Note: When you create a type alias specifically for a record, it also generates a record constructor. So our User type alias will also generate this function: User : String -> String -> String -> User The arguments are in the order they appear in the type alias declaration. You may want to use this sometimes. This is why it does work, in Peter’s example, to write MainModel 1. I think Peter’s question is whether this is intended to work for “an alias of an alias” too. I think there are useful reasons for this to be the case. In the example I posted, having `ManagedBook` be a constructor would allow you to more easily write, e.g., a JSON Decoder for a ManagedBook. But I can see arguments both ways. > On Jun 22, 2016, at 5:50 PM, Nick H <[email protected]> wrote: > > this is syntactically incorrect, because "Model" is not a type constructor. > > the correct syntax would simply be > > init: Model > init = { int = 1 } > > On Wed, Jun 22, 2016 at 1:05 AM, Peter Damoc <[email protected] > <mailto:[email protected]>> wrote: > This does not work: > > type alias MainModel = { int : Int} > > type alias Model = MainModel > > init = Model 1 > > and I'm wondering if this is a bug or the expected behavior. > > > > > > > -- > There is NO FATE, we are the creators. > blog: http://damoc.ro/ <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] > <mailto:[email protected]>. > For more options, visit https://groups.google.com/d/optout > <https://groups.google.com/d/optout>. > > > -- > You received this message because you are subscribed to a topic in the Google > Groups "Elm Discuss" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/elm-discuss/5Lw3D0DmlCo/unsubscribe > <https://groups.google.com/d/topic/elm-discuss/5Lw3D0DmlCo/unsubscribe>. > To unsubscribe from this group and all its topics, send an email to > [email protected] > <mailto:[email protected]>. > For more options, visit https://groups.google.com/d/optout > <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.
