这是我目前所拥有的:
instance Monad Ptr where
return = pure
(>>=) (Ptr t) f = f t
抛出的错误是:
• Couldn't match a lifted type with an unlifted type
When matching types
a :: *
GHC.Prim.Addr# :: TYPE 'GHC.Types.AddrRep
• In the first argument of ‘f’, namely ‘t’
In the expression: f t
In an equation for ‘>>=’: (>>=) (Ptr t) f = f t
• Relevant bindings include
f :: a -> Ptr b (bound at RegionalMemory.hs:16:19)
(>>=) :: Ptr a -> (a -> Ptr b) -> Ptr b
(bound at RegionalMemory.hs:16:5)
|
16 | (>>=) (Ptr t) f = f t
| ^
我不太明白这个错误。我做错了什么?