mirror of
https://github.com/urbit/shrub.git
synced 2024-12-19 08:32:39 +03:00
king: remove dead code in noun conversion.
This commit is contained in:
parent
be1cfc16c4
commit
bf2aa9d2e6
@ -22,78 +22,6 @@ import qualified Control.Monad.Fail as Fail
|
||||
type ParseStack = [Text]
|
||||
|
||||
|
||||
-- IResult ---------------------------------------------------------------------
|
||||
|
||||
data IResult a = IError ParseStack String | ISuccess a
|
||||
deriving (Eq, Show, Typeable, Functor, Foldable, Traversable)
|
||||
|
||||
instance Applicative IResult where
|
||||
pure = ISuccess
|
||||
(<*>) = ap
|
||||
|
||||
instance Fail.MonadFail IResult where
|
||||
fail err = IError [] err
|
||||
|
||||
instance Monad IResult where
|
||||
return = pure
|
||||
fail = Fail.fail
|
||||
ISuccess a >>= k = k a
|
||||
IError path err >>= _ = IError path err
|
||||
|
||||
instance MonadPlus IResult where
|
||||
mzero = fail "mzero"
|
||||
mplus a@(ISuccess _) _ = a
|
||||
mplus _ b = b
|
||||
|
||||
instance Alternative IResult where
|
||||
empty = mzero
|
||||
(<|>) = mplus
|
||||
|
||||
instance Semigroup (IResult a) where
|
||||
(<>) = mplus
|
||||
|
||||
instance Monoid (IResult a) where
|
||||
mempty = fail "mempty"
|
||||
mappend = (<>)
|
||||
|
||||
|
||||
-- Result ----------------------------------------------------------------------
|
||||
|
||||
data Result a = Error String | Success a
|
||||
deriving (Eq, Show, Typeable, Functor, Foldable, Traversable)
|
||||
|
||||
instance Applicative Result where
|
||||
pure = Success
|
||||
(<*>) = ap
|
||||
|
||||
instance Fail.MonadFail Result where
|
||||
fail err = Error err
|
||||
|
||||
instance Monad Result where
|
||||
return = pure
|
||||
fail = Fail.fail
|
||||
|
||||
Success a >>= k = k a
|
||||
Error err >>= _ = Error err
|
||||
|
||||
instance MonadPlus Result where
|
||||
mzero = fail "mzero"
|
||||
mplus a@(Success _) _ = a
|
||||
mplus _ b = b
|
||||
|
||||
instance Alternative Result where
|
||||
empty = mzero
|
||||
(<|>) = mplus
|
||||
|
||||
instance Semigroup (Result a) where
|
||||
(<>) = mplus
|
||||
{-# INLINE (<>) #-}
|
||||
|
||||
instance Monoid (Result a) where
|
||||
mempty = fail "mempty"
|
||||
mappend = (<>)
|
||||
|
||||
|
||||
-- "Parser" --------------------------------------------------------------------
|
||||
|
||||
type Failure f r = ParseStack -> String -> f r
|
||||
|
Loading…
Reference in New Issue
Block a user