Open premek opened 6 years ago
@premek AddElement
is a function that takes an Int
and an IntList
and produces a value of type IntList
. If it is explained that way, is it clearer?
Absolutely yes. It got clearer later in the tour. Maybe also mention where does it come from? Is it a part of standard library? Or just omitted from the example for simplicity?
@premek It's a user defined type and AddElement
becomes availble with this definition:
data IntList = Empty | AddElement Int IntList
Should that be more explicit as well?
now it's less clear to me again :) sorry
I would expect this line to mean something like Let type IntList be an empty list or an Int followed by IntList
Does this line also defines AddElement?
It means what you stated above - you can think of AddElement
as a tag that signals that an Int
and IntList
must follow in that order right after. Empty
and AddElement
are like labels for each of the ways you can construct a value of type IntList
.
Yes, the line also defines AddElement
and Empty
.
All right, makes sense. So if you can explain it like this in one sentence in the tour I think it may help others too. Thanks
On Mon, 9 Apr 2018, 16:44 Rahul Muttineni, notifications@github.com wrote:
It means what you stated above - you can think of AddElement as a tag that signals that an Int and IntList must follow in that order right after. Empty and AddElement are like labels for each of the ways you can construct a value of type IntList.
Yes, the line also defines AddElement and Empty.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/typelead/eta/issues/728#issuecomment-379777117, or mute the thread https://github.com/notifications/unsubscribe-auth/ABF6EWOMYNm753XlpJSVxxbE5fFgb1sCks5tm3PYgaJpZM4TMXnq .
Thank you for letting us know it was confusing! :)
I think it is confusing without knowing what AddElement is
Source Code: