So the definition of List might look like:
type List a
| Cons a (List a)
That’s exactly how the definition of List would look like if it didn’t have
a native implementation.
So it seems you already know everything.
2016-09-20 17:25 GMT+02:00 'Rupert Smith' via Elm Discuss <
> Some more questions about types. I just ran into the recursive 'type
> alias' issue:
> which is clear enough. It seems a bit of a shame that some of this
> documentation is a bit buried away - it really feels like this should be in
> the syntax guide (or whatever chapter comes after the syntax guide).
> Anyway, the other questions:
> Can type definitions be recursive? as per ML, I think the answer is yes.
> type Expression
> = Integer Int
> | Sum Expression Expression
> for a simple syntax tree representing expressions over integers and
> I have seen some type definitions like this:
> type Cmd msg = Cmd
> but I am more used to seeing type definitions that look like this:
> type Msg
> = SomeMsg String
> | ...
> What does the 'msg' parameter on this type do? Does it just mean that the
> type is polymorphic and the 'msg' is the type parameter? So the definition
> of List might look like:
> type List a
> = Nil
> | Cons a (List a)
> 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 elm-discuss+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to the Google Groups "Elm
To unsubscribe from this group and stop receiving emails from it, send an email
For more options, visit https://groups.google.com/d/optout.