I'm trying to complete the monadLeftIdentity
proof for the following data type:
data ErrorM : (a : Type) -> Type where
AllGood : a -> ErrorM a
Error : String -> ErrorM a
instance Monad ErrorM where
(AllGood x) >>= f = f x
(Error err) >>= f = Error err
instance VerifiedMonad ErrorM where
monadApplicative (AllGood f) (AllGood x) = Refl
monadApplicative (Error err) (AllGood x) = Refl
monadApplicative (AllGood f) (Error err) = Refl
monadApplicative (Error er1) (Error er2) = Refl
monadLeftIdentity x f = ?z
I've left out the instances for Functor
, Applicative
and their Verified
counterparts, as they're quite verbose and trivial. Do let me know, can paste them all here.
I've tried to rewrite return x
as pure x
or AllGood x
, but have been unsuccessful in doing so (the rewrite does nothing to the proof state).
I've also tried to refine return x
like so:
monadLeftIdentity x f with (return x)
monadLeftIdentity x' f | AllGood x' = ?z
but I get the following err msg:
`-- Error.idr line 51 col 22:
When elaborating left hand side of with block in Prelude.Monad.Astra.Error.ErrorM instance of Prelude.Monad.VerifiedMonad, method monadLeftIdentity:
Can't match on with block in Prelude.Monad.Astra.Error.ErrorM instance of Prelude.Monad.VerifiedMonad, method monadLeftIdentity a (AllGood x') x' b f return
How does one go about this?