-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Graph indexed monads. -- -- Graph indexed monads. @package graphted @version 0.1.0.2 -- | description starting at first column module Data.Functor.Graph -- | Graph indexed functor. class GFunctor (f :: p -> * -> *) where type Fmap f (i :: p) :: p type Fconst f (i :: p) :: p type Fmap f i = i type Fconst f i = Fmap f i gconst = gmap . const where { type family Fmap f (i :: p) :: p; type family Fconst f (i :: p) :: p; type Fmap f i = i; type Fconst f i = Fmap f i; } -- | Map a function over over the functor (fmap). gmap :: GFunctor f => (a -> b) -> f i a -> f (Fmap f i) b -- | Replace all values with a constant (<$). -- -- Default implementation requires the default instance of Fconst. gconst :: GFunctor f => a -> f i b -> f (Fconst f i) a -- | Replace all values with a constant (<$). -- -- Default implementation requires the default instance of Fconst. gconst :: (GFunctor f, Fconst f i ~ Fmap f i) => a -> f i b -> f (Fconst f i) a module Control.Graphted.Class -- | Base class that all Graph-indexed types may implement. class Graphted (f :: p -> * -> *) where type Unit f :: p type Inv f (i :: p) (j :: p) :: Constraint type Combine f (i :: p) (j :: p) :: p type Inv f i j = () where { type family Unit f :: p; type family Inv f (i :: p) (j :: p) :: Constraint; type family Combine f (i :: p) (j :: p) :: p; type Inv f i j = (); } module Data.Pointed.Graph -- | Graph indexed pointed functor. class GPointed (f :: p -> * -> *) where type Pure f :: p type Pure f = Unit f gpoint = gpoint' @p @f @(Pure f) where { type family Pure f :: p; type Pure f = Unit f; } -- | Return a pointed functor indexed by the Pure type instance -- (pure). -- --
--   >>> :t gpoint @_ @(GWrapped Maybe) "Hello, World"
--   :: GWrapped Maybe () [Char]
--   
gpoint :: forall a. GPointed f => a -> f (Pure f) a -- | Return a pointed functor indexed by a type t in the domain of -- p. -- -- Accessible with type applications, e.g.: -- --
--   >>> :t gpoint' @_ @(GWrapped Maybe) @Int
--   gpoint' @_ @(GWrapped Maybe) @Int :: a -> GWrapped Maybe Int a
--   
gpoint' :: forall t a. GPointed f => a -> f t a module Control.Applicative.Graph -- | Graph indexed applicative functor. class (GFunctor f, GPointed f) => GApplicative (f :: p -> * -> *) where type Apply f (i :: p) (j :: p) :: p type Then f (i :: p) (j :: p) :: p type But f (i :: p) (j :: p) :: p type Apply f i j = Combine f i j type Then f i j = Apply f (Fconst f i) j type But f i j = Apply f (Apply f (Pure f) i) j gthen a b = (id `gconst` a) `gap` b gbut a b = gpoint const `gap` a `gap` b where { type family Apply f (i :: p) (j :: p) :: p; type family Then f (i :: p) (j :: p) :: p; type family But f (i :: p) (j :: p) :: p; type Apply f i j = Combine f i j; type Then f i j = Apply f (Fconst f i) j; type But f i j = Apply f (Apply f (Pure f) i) j; } -- | Sequential application (<*>). gap :: (GApplicative f, Inv f i j) => f i (a -> b) -> f j a -> f (Apply f i j) b -- | Sequence actions, discarding the value of the first argument -- (*>). -- -- Default implementation requires the default instance of Then. gthen :: (GApplicative f, Inv f i j) => f i a -> f j b -> f (Then f i j) b -- | Sequence actions, discarding the value of the first argument -- (*>). -- -- Default implementation requires the default instance of Then. gthen :: (GApplicative f, Apply f (Fconst f i) j ~ Then f i j, Inv f (Fconst f i) j) => f i a -> f j b -> f (Then f i j) b -- | Sequence actions, discarding values of the second argument -- (<*). -- -- Default implementation requires the default instance of But. gbut :: (GApplicative f, Inv f i j) => f i a -> f j b -> f (But f i j) a -- | Sequence actions, discarding values of the second argument -- (<*). -- -- Default implementation requires the default instance of But. gbut :: (GApplicative f, Apply f (Apply f (Pure f) i) j ~ But f i j, Inv f (Pure f) i, Inv f (Apply f (Pure f) i) j) => f i a -> f j b -> f (But f i j) a module Control.Monad.Graph -- | Graph indexed monad. class GApplicative m => GMonad (m :: p -> * -> *) where type Bind m (i :: p) (j :: p) :: p type Join m (i :: p) (j :: p) :: p type Bind m i j = Combine m i j type Join m i j = Bind m i j gjoin x = x `gbind` id where { type family Bind m (i :: p) (j :: p) :: p; type family Join m (i :: p) (j :: p) :: p; type Bind m i j = Combine m i j; type Join m i j = Bind m i j; } -- | Sequentially compose two actions, with the second dependent on the -- first. gbind :: (GMonad m, Inv m i j) => m i a -> (a -> m j b) -> m (Bind m i j) b -- | Remove one level of nested structure. -- -- Default implementation requires the default instance of Join. gjoin :: (GMonad m, Inv m i j) => m i (m j b) -> m (Join m i j) b -- | Remove one level of nested structure. -- -- Default implementation requires the default instance of Join. gjoin :: (GMonad m, Bind m i j ~ Join m i j, Inv m i j) => m i (m j b) -> m (Join m i j) b module Control.MonadZero.Graph -- | Graph indexed monad with a monoidal zero. -- -- See the typeclassopedia -- https://wiki.haskell.org/Typeclassopedia. class GMonad m => GMonadZero (m :: p -> * -> *) where type Zero m :: p type Zero m = Unit m where { type family Zero m :: p; type Zero m = Unit m; } -- | Identity element. gzero :: GMonadZero m => m (Zero m) a module Control.MonadFail.Graph -- | Graph indexed monad with failure. class GMonad m => GMonadFail (m :: p -> * -> *) where type Fail m :: p type Fail m = Unit m gfail _ = gzero where { type family Fail m :: p; type Fail m = Unit m; } -- | Fail with a message. -- -- Default implementation requires the default instance of Fail. gfail :: GMonadFail m => String -> m (Fail m) a -- | Fail with a message. -- -- Default implementation requires the default instance of Fail. gfail :: (GMonadFail m, GMonadZero m, Zero m ~ Fail m) => String -> m (Fail m) a module Control.MonadOr.Graph -- | Graph indexed monad with a monoidal operation satisfying the left -- catch law. -- -- See the typeclassopedia -- https://wiki.haskell.org/Typeclassopedia. class GMonadZero m => GMonadOr (m :: p -> * -> *) where type Or m (i :: p) (j :: p) :: p type Or m i j = Combine m i j where { type family Or m (i :: p) (j :: p) :: p; type Or m i j = Combine m i j; } -- | An associative binary operation (<|>). gorelse :: GMonadOr m => m i a -> m j a -> m (Or m i j) a module Control.MonadPlus.Graph -- | Graph indexed monad with a monoidal operation satisfying the left -- distribution law. -- -- See the typeclassopedia -- https://wiki.haskell.org/Typeclassopedia. class GMonadZero m => GMonadPlus (m :: p -> * -> *) where type Plus m (i :: p) (j :: p) :: p type Plus m i j = Combine m i j where { type family Plus m (i :: p) (j :: p) :: p; type Plus m i j = Combine m i j; } -- | An associative binary operation (mplus). gplus :: GMonadPlus m => m i a -> m j a -> m (Plus m i j) a module Control.Graphted module Data.GWrapped -- | Wrap a non-indexed type constructor: newtype GWrapped (m :: * -> *) (p :: *) a GWrapped :: m a -> GWrapped a [unG] :: GWrapped a -> m a -- | Lift an object to GWrapped. liftG :: m a -> GWrapped m p a instance Control.Graphted.Class.Graphted (Data.GWrapped.GWrapped m) instance GHC.Base.Applicative f => Data.Pointed.Graph.GPointed (Data.GWrapped.GWrapped f) instance GHC.Base.Functor f => Data.Functor.Graph.GFunctor (Data.GWrapped.GWrapped f) instance GHC.Base.Applicative f => Control.Applicative.Graph.GApplicative (Data.GWrapped.GWrapped f) instance GHC.Base.Monad m => Control.Monad.Graph.GMonad (Data.GWrapped.GWrapped m) instance GHC.Base.Monad m => Control.MonadFail.Graph.GMonadFail (Data.GWrapped.GWrapped m) instance GHC.Base.MonadPlus m => Control.MonadZero.Graph.GMonadZero (Data.GWrapped.GWrapped m) instance GHC.Base.MonadPlus m => Control.MonadPlus.Graph.GMonadPlus (Data.GWrapped.GWrapped m) instance (GHC.Base.Alternative m, GHC.Base.MonadPlus m) => Control.MonadOr.Graph.GMonadOr (Data.GWrapped.GWrapped m) module Prelude.Graphted fmap :: GFunctor f => (a -> b) -> f i a -> f (Fmap f i) b (<$) :: GFunctor f => b -> f i a -> f (Fconst f i) b infixl 4 <$ (<$>) :: GFunctor f => (a -> b) -> f i a -> f (Fmap f i) b pure :: GPointed f => a -> f (Pure f) a (<*>) :: (GApplicative f, _) => f i (a -> b) -> f j a -> f (Apply f i j) b infixl 4 <*> (*>) :: (GApplicative f, _) => f i a -> f j b -> f (Then f i j) b infixl 4 *> (<*) :: (GApplicative f, _) => f i a -> f j b -> f (But f i j) a infixl 4 <* return :: GPointed m => a -> m (Pure m) a (>>=) :: (GMonad m, Inv m i j) => m i a -> (a -> m j b) -> m (Bind m i j) b infixl 1 >>= (=<<) :: (GMonad m, Inv m i j) => (a -> m j b) -> m i a -> m (Bind m i j) b infixr 1 =<< (>>) :: (GApplicative m, _) => m i a -> m j b -> m (Then m i j) b infixl 1 >> fail :: GMonadFail m => String -> m (Fail m) a zero :: GMonadZero m => m (Zero m) a (<+>) :: (GMonadPlus f, _) => f i a -> f j a -> f (Plus f i j) a (<|>) :: (GMonadOr f, _) => f i a -> f j a -> f (Or f i j) a (<**>) :: (GApplicative f, _) => f i1 a -> f i2 (a -> b) -> f (Apply f (Apply f (Pure f) i1) i2) b infixl 4 <**> liftA :: (GApplicative f, _) => (a -> b) -> f i1 a -> f (Apply f (Pure f) i1) b liftA2 :: (GApplicative f, _) => (a1 -> a2 -> b) -> f i1 a1 -> f i2 a2 -> f (Apply f (Apply f (Pure f) i1) i2) b liftA3 :: (GApplicative f, _) => (a1 -> a2 -> a3 -> b) -> f i1 a1 -> f i2 a2 -> f i3 a3 -> f (Apply f (Apply f (Apply f (Pure f) i1) i2) i3) b join :: (GMonad m, Inv m i j) => m i (m j b) -> m (Join m i j) b liftM :: (GApplicative m, _) => (t -> b) -> m j t -> m (Fmap m j) b liftM2 :: (GApplicative m, _) => (t1 -> t -> b) -> m i1 t1 -> m i t -> m (Apply m (Fmap m i1) i) b liftM3 :: (GApplicative m, _) => (t2 -> t1 -> t -> b) -> m i2 t2 -> m i1 t1 -> m i t -> m (Apply m (Apply m (Fmap m i2) i1) i) b liftM4 :: (GApplicative m, _) => (t3 -> t2 -> t1 -> t -> b) -> m i3 t3 -> m i2 t2 -> m i1 t1 -> m i t -> m (Apply m (Apply m (Apply m (Fmap m i3) i2) i1) i) b liftM5 :: (GApplicative m, _) => (t4 -> t3 -> t2 -> t1 -> t -> b) -> m i4 t4 -> m i3 t3 -> m i2 t2 -> m i1 t1 -> m i t -> m (Apply m (Apply m (Apply m (Apply m (Fmap m i4) i3) i2) i1) i) b ap :: (GApplicative m, Inv m (Fmap m i) j) => m i (t -> b) -> m j t -> m (Apply m (Fmap m i) j) b mapM_ :: (GApplicative m, Foldable t, Apply m (Fmap m i) (Pure m) ~ Pure m, _) => (a1 -> m i a) -> t a1 -> m (Pure m) () sequence_ :: (GApplicative m, Foldable t, Apply m (Fmap m i) (Pure m) ~ Pure m, _) => t (m i a) -> m (Pure m) ()