diff options
author | Profpatsch <mail@profpatsch.de> | 2023-01-08T22·41+0100 |
---|---|---|
committer | Profpatsch <mail@profpatsch.de> | 2023-01-08T23·10+0000 |
commit | cd40585ea4481625ed8c198ee56ce2e453a1cd9c (patch) | |
tree | d01e057271c64df72624e022b67265141b4d13e5 /users/Profpatsch/my-prelude/MyPrelude.hs | |
parent | 8cdefc5b253109d319267b68f0f45c0d3f021d17 (diff) |
feat(users/Profpatsch/netencode): Add initial Haskell parser r/5632
A simple categorical parser that does not implement Monad, and does not contain an `m` and some rudementary error message handling. In the future I’d probably want to wrap everything in an additional `m`, so that subparsers can somehow use `Selective` to throw errors from within `m` that contain the parsing context if at all possible. Hard to do without Monad, I have to say. Not even stuff like `StateT` works without the inner `m` implementing `Monad`. Change-Id: I1366eda606ddfb019637b09c82d8b0e30bd4e318 Reviewed-on: https://cl.tvl.fyi/c/depot/+/7797 Tested-by: BuildkiteCI Reviewed-by: Profpatsch <mail@profpatsch.de>
Diffstat (limited to 'users/Profpatsch/my-prelude/MyPrelude.hs')
-rw-r--r-- | users/Profpatsch/my-prelude/MyPrelude.hs | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/users/Profpatsch/my-prelude/MyPrelude.hs b/users/Profpatsch/my-prelude/MyPrelude.hs index 4ef59c05ffba..1be248d091a9 100644 --- a/users/Profpatsch/my-prelude/MyPrelude.hs +++ b/users/Profpatsch/my-prelude/MyPrelude.hs @@ -1,4 +1,3 @@ -{-# LANGUAGE GHC2021 #-} {-# LANGUAGE ImplicitParams #-} {-# LANGUAGE LambdaCase #-} {-# LANGUAGE MagicHash #-} @@ -52,10 +51,10 @@ module MyPrelude when, unless, guard, - ExceptT, + ExceptT (..), runExceptT, - MonadError, - throwError, + MonadThrow, + throwM, MonadIO, liftIO, MonadReader, @@ -79,6 +78,8 @@ module MyPrelude traverseFold, traverseFold1, traverseFoldDefault, + MonadTrans, + lift, -- * Data types Coercible, @@ -145,15 +146,15 @@ where import Control.Applicative ((<|>)) import Control.Category (Category, (>>>)) import Control.Monad (guard, join, unless, when) +import Control.Monad.Catch (MonadThrow (throwM)) import Control.Monad.Except - ( ExceptT, - MonadError, + ( ExceptT (..), runExceptT, - throwError, ) import Control.Monad.IO.Class (MonadIO, liftIO) import Control.Monad.Identity (Identity (Identity)) import Control.Monad.Reader (MonadReader, asks) +import Control.Monad.Trans (MonadTrans (lift)) import Data.Bifunctor (Bifunctor, bimap, first, second) import Data.ByteString ( ByteString, |