import Data.Generic.Rep as GR
import Data.Generic.Rep.Show (genericShow)
data IntOrBoolean2
= Int2 Int
| Boolean2 Boolean
-- note the underscore at the end for the `rep` parameter of class Generic
derive instance genericIntOrBoolean2 :: GR.Generic IntOrBoolean2 _
instance showIntOrBoolean2 :: Show IntOrBoolean2 where
show = genericShow
-- now we get a Show
instance infixFoldable :: Foldable Tree where
foldl f acc Leaf = acc
foldl f acc (Branch left node right) = foldl f (f (foldl f acc left) node) right
foldr = foldrDefault
foldMap = foldMapDefaultL
Any idea what I am doing wrong?
Nat m n = Nat (m ~> n)
but not with a record NatR m n = Nat { nat :: (m ~> n) }
use :: forall m n. Nat m n -> m Unit -> n Unit
use (Nat nat) = nat
useR :: forall m n. NatR m n -> m Unit -> n Unit
useR (NatR { nat }) = nat -- Error!
I get an error with useR
: Could not match type
a2
with type
Unit
while trying to match type m0 a2
with type m0 Unit
while checking that expression nat
has type m0 Unit -> n1 Unit
in value declaration useR
where n1 is a rigid type variable
bound at (line 0, column 0 - line 0, column 0)
m0 is a rigid type variable
bound at (line 0, column 0 - line 0, column 0)
a2 is a rigid type variable
bound at (line 17, column 34 - line 17, column 54)