This commit is contained in:
orion 2023-11-28 12:54:57 -06:00
parent df273eb635
commit 2a4ee6482d
Signed by: orion
GPG Key ID: 6D4165AE4C928719
2 changed files with 14 additions and 0 deletions

View File

@ -10,6 +10,7 @@ package:
- mmorph - mmorph
- newtype - newtype
- node-buffer - node-buffer
- parallel
- prelude - prelude
- simple-json - simple-json
- tailrec - tailrec

View File

@ -8,8 +8,10 @@ import Control.Monad.Morph (class MFunctor, class MMonad, embed, hoist)
import Control.Monad.Reader (class MonadAsk, class MonadReader, ReaderT(..), ask, runReaderT) import Control.Monad.Reader (class MonadAsk, class MonadReader, ReaderT(..), ask, runReaderT)
import Control.Monad.Rec.Class (class MonadRec) import Control.Monad.Rec.Class (class MonadRec)
import Control.Monad.Trans.Class (class MonadTrans, lift) import Control.Monad.Trans.Class (class MonadTrans, lift)
import Control.Parallel (class Parallel, parallel, sequential)
import Data.Bifunctor (lmap) import Data.Bifunctor (lmap)
import Data.Either (Either) import Data.Either (Either)
import Data.Functor.Compose (Compose(..))
import Data.Newtype (class Newtype, unwrap, wrap) import Data.Newtype (class Newtype, unwrap, wrap)
import Effect.Aff.Class (class MonadAff) import Effect.Aff.Class (class MonadAff)
import Effect.Class (class MonadEffect) import Effect.Class (class MonadEffect)
@ -17,6 +19,14 @@ import Effect.Exception as Effect.Exception
import Gitea.Config (Config) import Gitea.Config (Config)
import Gitea.Error as Gitea.Error import Gitea.Error as Gitea.Error
newtype GiteaParT :: (Type -> Type) -> Type -> Type
newtype GiteaParT m a = GiteaParT (ReaderT Config (Compose m (Either Gitea.Error.Error)) a)
derive instance Newtype (GiteaParT m a) _
derive newtype instance Functor m => Functor (GiteaParT m)
derive newtype instance Apply m => Apply (GiteaParT m)
derive newtype instance Applicative m => Applicative (GiteaParT m)
newtype GiteaT :: (Type -> Type) -> Type -> Type newtype GiteaT :: (Type -> Type) -> Type -> Type
newtype GiteaT m a = GiteaT (ReaderT Config (ExceptT Gitea.Error.Error m) a) newtype GiteaT m a = GiteaT (ReaderT Config (ExceptT Gitea.Error.Error m) a)
@ -42,6 +52,9 @@ derive newtype instance MonadAff m => MonadAff (GiteaT m)
derive newtype instance Monad m => MonadError Gitea.Error.Error (GiteaT m) derive newtype instance Monad m => MonadError Gitea.Error.Error (GiteaT m)
derive newtype instance Monad m => MonadThrow Gitea.Error.Error (GiteaT m) derive newtype instance Monad m => MonadThrow Gitea.Error.Error (GiteaT m)
derive newtype instance MonadRec m => MonadRec (GiteaT m) derive newtype instance MonadRec m => MonadRec (GiteaT m)
instance (Parallel f m, Monad m) => Parallel (GiteaParT f) (GiteaT m) where
parallel m = wrap $ parallel $ unwrap m
sequential f = wrap $ sequential $ unwrap f
derive newtype instance Monad m => Functor (GiteaT m) derive newtype instance Monad m => Functor (GiteaT m)
derive newtype instance Monad m => Apply (GiteaT m) derive newtype instance Monad m => Apply (GiteaT m)