1module Control.Catchable
4import Control.Monad.Reader
5import Control.Monad.Writer
6import Control.Monad.RWS
7import Control.Monad.Trans
11interface Catchable (m : Type -> Type) t | m where
13 catch : m a -> (t -> m a) -> m a
15implementation Catchable Maybe () where
16 catch Nothing h = h ()
17 catch (Just x) h = Just x
21implementation Catchable (Either a) a where
22 catch (Left err) h = h err
23 catch (Right x) h = (Right x)
27implementation Catchable (IOExcept err) err where
28 catch (IOM prog) h = IOM (do p' <- prog
30 Left e => let IOM he = h e in he
31 Right val => pure (Right val))
34implementation Catchable List () where
40||| Adapted from https://hackage.haskell.org/package/mtl-2.2.1/docs/src/Control.Monad.Error.Class.html#line-138
41implementation (Monad m, Catchable m t) => Catchable (ReaderT r m) t where
42 -- TODO: rewrite this with apply2way combinator when implemented
43 catch m h = RD $ \ r => catch (runReaderT m r) (\ e => runReaderT (h e) r)
44 -- catch m h = RD $ \ r => catch (runReaderT m r) (\ e => runReaderT (h e) r)
48||| Adapted from https://hackage.haskell.org/package/transformers-0.5.4.0/docs/src/Control.Monad.Trans.Writer.Lazy.html#local-6989586621679059673
49implementation (Monad m, Monoid w, Catchable m t) => Catchable (WriterT w m) t where
50 catch m h = WR $ runWriterT m `catch` runWriterT . h
53||| Adapted from https://hackage.haskell.org/package/mtl-2.2.1/docs/src/Control.Monad.Error.Class.html#line-138
54implementation (Monad m, Monoid w, Catchable m t) => Catchable (RWST r w s m) t where
55 catch m h = MkRWST $ \ r, s => runRWST m r s `catch` \ e => runRWST (h e) r s
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list