Even though this was probably not your intent, showing how to apply the remaining argument might clarify things. For example, you could put your Array Int
into a NonEmpty
collection of another Array
of arrays or a List
of arrays. This parent collection is what that t1
type variable in the error message represents.
> a = NonEmpty [1, 2]
> b = a [[3, 4], [5, 6]]
> b
(NonEmpty [1,2] [[3,4],[5,6]])
> :t b
NonEmpty Array (Array Int)
> c = a ([3, 4] : [5, 6] : Nil)
> c
(NonEmpty [1,2] ([3,4] : [5,6] : Nil))
> :t c
NonEmpty List (Array Int)
The NonEmpty
syntax tripped me up too when going through the book, so I figured it’s about time to add some more beginner-friendly examples to the docs (PR). Looking forward to when these can be replaced with doctest.
Also, I’ll add a note in the book that show
should produce what you’d need to paste into the repl to create the value being shown. (Edit: PR)