Use `derive newtype instance` to save some boilerplate

This commit is contained in:
Danila Fedorin 2023-03-03 22:56:32 -08:00
parent 734f231250
commit 80dc5b6a2c
1 changed files with 5 additions and 17 deletions

View File

@ -32,24 +32,12 @@ newtype UnifyT k f m a = MkUnifyT (StateT (UnificationState k f) m a)
derive instance Newtype (UnifyT k f m a) _
derive instance Functor m => Functor (UnifyT k f m)
instance Monad m => Apply (UnifyT k f m) where
apply m1 m2 = MkUnifyT $ apply (un MkUnifyT m1) (un MkUnifyT m2)
instance Monad m => Applicative (UnifyT k f m) where
pure a = MkUnifyT $ pure a
instance Monad m => Bind (UnifyT k f m) where
bind m f = MkUnifyT $ (un MkUnifyT m) >>= (un MkUnifyT <<< f)
derive newtype instance Monad m => Apply (UnifyT k f m)
derive newtype instance Monad m => Applicative (UnifyT k f m)
derive newtype instance Monad m => Bind (UnifyT k f m)
instance Monad m => Monad (UnifyT k f m)
instance (Monad m, Alt m) => Alt (UnifyT k f m) where
alt = over2 MkUnifyT alt
instance (Monad m, Plus m) => Plus (UnifyT k f m) where
empty = MkUnifyT empty
derive newtype instance (Monad m, Alt m) => Alt (UnifyT k f m)
derive newtype instance (Monad m, Plus m) => Plus (UnifyT k f m)
instance (Monad m, Alternative m) => Alternative (UnifyT k f m)
instance (MonadPlus m) => MonadPlus (UnifyT k f m)