1{-# OPTIONS_GHC -Wall #-}
2{-# LANGUAGE Rank2Types #-}
14-- TODO try adding INLINE to warn, throw, (>>=), etc.
17import qualified Data.OneOrMore as OneOrMore
18import qualified Reporting.Warning as Warning
25newtype Result info warnings error a =
30 -> (info -> warnings -> OneOrMore.OneOrMore error -> result)
31 -> (info -> warnings -> a -> result)
36run :: Result () [w] e a -> ([w], Either [e] a)
39 (\() w e -> (reverse w, Left (OneOrMore.toList e)))
40 (\() w a -> (reverse w, Right a))
48ok :: a -> Result i w e a
50 Result $ \i w _ good ->
54warn :: Warning.Warning -> Result i [Warning.Warning] e ()
56 Result $ \i warnings _ good ->
57 good i (warning:warnings) ()
60throw :: e -> Result i w e a
62 Result $ \i w bad _ ->
63 bad i w (OneOrMore.one e)
66mapError :: (e -> e') -> Result i w e a -> Result i w e' a
67mapError func (Result k) =
68 Result $ \i w bad good ->
71 bad i1 w1 (OneOrMore.map func e1)
77-- FANCY INSTANCE STUFF
80instance Functor (Result i w e) where
81 fmap func (Result k) =
82 Result $ \i w bad good ->
85 good i1 w1 (func value)
90instance Applicative (Result i w e) where
93 (<*>) (Result kf) (Result kv) =
94 Result $ \i w bad good ->
98 bad2 i2 w2 e2 = bad i2 w2 (OneOrMore.more e1 e2)
99 good2 i2 w2 _value = bad i2 w2 e1
105 bad2 i2 w2 e2 = bad i2 w2 e2
106 good2 i2 w2 value = good i2 w2 (func value)
113instance Monad (Result i w e) where
116 (>>=) (Result ka) callback =
117 Result $ \i w bad good ->
121 Result kb -> kb i1 w1 bad good
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