Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
Ah that makes sense. Thank you both.
Yep! It does little more than allow us to define new
instance
s which differ from the inner type.Precisely.
x and y are of type
[a]
, notLengthList a
.Consider these two ways of writing a function:
and
In the first example, the argument is simply bound to the identifier "x"; hence, x has type
LengthList a
. In the second example, however, we pattern-match on the argument, and bind the contents of the LengthList to the indentifier "x". So in the second example x has type[a]
.Hope that helps.
What allows you to call length on x and y, if they are of type LengthList? Why do they still respond to list functions?
Maybe the greater question is - is newtype LengthList simple a wrapper?
Also... is
instance Ord a
... defining how LengthList will respond to the functions defined by the Ord typeclass?Absolutely.
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution