I'm trying to convert several projects to classy-prelude at the moment. While most behaviour seems quite straightforward to me, the (head . head) gives mysterious errors on a simple 2D list.
Consider the following GHCi session:
Prelude> (head . head) [[1,2],[3,4]]
1
Let's try this with ghci -XNoImplicitPrelude and classy-prelude:
> import ClassyPrelude
ClassyPrelude> (head . head) [[1,2],[3,4]]
<interactive>:10:1:
Couldn't match type `MinLen (Succ nat1) mono1' with `[[t0]]'
Expected type: [[t0]] -> Element mono0
Actual type: MinLen (Succ nat1) mono1 -> Element mono0
The function `head . head' is applied to one argument,
but its type `MinLen (Succ nat1) mono1 -> Element mono0'
has only one
In the expression: (head . head) [[1, 2], [3, 4]]
In an equation for `it': it = (head . head) [[1, 2], [3, 4]]
I assume GHC simply can't resolve the types for multidimensional lists correctly. Is there any way I can help it without resorting to (Prelude.head . Prelude.head)?
MinLen (Succ nat1) mono1=> I think you need a non-empty list type there - Mauricio Scheffer[[1,2],[3,4]]is non-empty in both dimensions, and GHC should be able to derive an Int type from it (it can do it forPrelude.head) - Uli KöhlerPrelude.head, being a Partial function, fails witherroron non-empty lists,classy-preludetried to solve this problem by defining non-empty lists as a different types? - Uli Köhler