packages feed

graphted 0.1.0.2 → 0.1.5.0

raw patch · 5 files changed

+52/−19 lines, 5 filesdep ~basePVP: major bump suggested

API removals or changes: PVP suggests a major version bump

Dependency ranges changed: base

API changes (from Hackage documentation)

- Data.Pointed.Graph: gpoint' :: forall t a. GPointed f => a -> f t a
- Prelude.Graphted: mapM_ :: (GApplicative m, Foldable t, Apply m (Fmap m i) (Pure m) ~ Pure m, _) => (a1 -> m i a) -> t a1 -> m (Pure m) ()
- Prelude.Graphted: sequence_ :: (GApplicative m, Foldable t, Apply m (Fmap m i) (Pure m) ~ Pure m, _) => t (m i a) -> m (Pure m) ()
- Data.Pointed.Graph: class GPointed (f :: p -> * -> *) where type Pure f :: p type Pure f = Unit f gpoint = gpoint' @p @f @(Pure f) where {
+ Data.Pointed.Graph: class GPointed (f :: p -> * -> *) where type Pure f :: p type Pure f = Unit f where {
- Prelude.Graphted: (*>) :: (GApplicative f, _) => f i a -> f j b -> f (Then f i j) b
+ Prelude.Graphted: (*>) :: (GApplicative f, Inv f i j) => f i a -> f j b -> f (Then f i j) b
- Prelude.Graphted: (<*) :: (GApplicative f, _) => f i a -> f j b -> f (But f i j) a
+ Prelude.Graphted: (<*) :: (GApplicative f, Inv f i j) => f i a -> f j b -> f (But f i j) a
- Prelude.Graphted: (<**>) :: (GApplicative f, _) => f i1 a -> f i2 (a -> b) -> f (Apply f (Apply f (Pure f) i1) i2) b
+ Prelude.Graphted: (<**>) :: (GApplicative f, Inv f (Pure f) i1, Inv f ((Apply f (Pure f) i1)) i2) => f i1 a -> f i2 (a -> b) -> f (Apply f (Apply f (Pure f) i1) i2) b
- Prelude.Graphted: (<*>) :: (GApplicative f, _) => f i (a -> b) -> f j a -> f (Apply f i j) b
+ Prelude.Graphted: (<*>) :: (GApplicative f, Inv f i j) => f i (a -> b) -> f j a -> f (Apply f i j) b
- Prelude.Graphted: (<+>) :: (GMonadPlus f, _) => f i a -> f j a -> f (Plus f i j) a
+ Prelude.Graphted: (<+>) :: (GMonadPlus f, Inv f i j) => f i a -> f j a -> f (Plus f i j) a
- Prelude.Graphted: (<|>) :: (GMonadOr f, _) => f i a -> f j a -> f (Or f i j) a
+ Prelude.Graphted: (<|>) :: (GMonadOr f, Inv f i j) => f i a -> f j a -> f (Or f i j) a
- Prelude.Graphted: (>>) :: (GApplicative m, _) => m i a -> m j b -> m (Then m i j) b
+ Prelude.Graphted: (>>) :: (GApplicative m, Inv m i j) => m i a -> m j b -> m (Then m i j) b
- Prelude.Graphted: ap :: (GApplicative m, Inv m (Fmap m i) j) => m i (t -> b) -> m j t -> m (Apply m (Fmap m i) j) b
+ Prelude.Graphted: ap :: ((~#) p p (Bind p m j (Pure p m)) (Fmap p m j), GMonad p m, Inv p m j (Pure p m)) => (t -> b) -> m j t -> m (Fmap p m j) b

Files

graphted.cabal view
@@ -1,5 +1,5 @@ name:                graphted-version:             0.1.0.2+version:             0.1.5.0 synopsis:    Graph indexed monads. -- description: TODO homepage:            https://github.com/aaronfriel/graphted#readme@@ -8,7 +8,7 @@ author:              Aaron Friel maintainer:          mayreply@aaronfriel.com copyright:           BSD3-category:            Web+category:            Control build-type:          Simple extra-source-files:  README.md cabal-version:       >=1.10@@ -27,8 +27,9 @@                      , Data.Pointed.Graph                      , Data.GWrapped                      , Prelude.Graphted-  build-depends:       base >= 4.7 && < 5+  build-depends:       base >= 4.8 && < 5   default-language:    Haskell2010+  ghc-options:         -fno-warn-partial-type-signatures  source-repository head   type:     git
src/Control/Graphted/Class.hs view
@@ -10,14 +10,19 @@  -} +{-# LANGUAGE CPP #-}+ {-# LANGUAGE ConstraintKinds #-} {-# LANGUAGE PolyKinds       #-} {-# LANGUAGE TypeFamilies    #-}-{-# LANGUAGE TypeInType      #-}  module Control.Graphted.Class where -import Data.Kind (type (*), Constraint)+#if __GLASGOW_HASKELL__ >= 801+import Data.Kind (Constraint)+#else+import GHC.Exts (Constraint)+#endif  -- | Base class that all Graph-indexed types may implement. --
src/Data/GWrapped.hs view
@@ -9,6 +9,8 @@  -} +{-# LANGUAGE CPP #-}+ {-# LANGUAGE GADTs         #-} {-# LANGUAGE PolyKinds     #-} {-# LANGUAGE TypeFamilies  #-}@@ -20,7 +22,7 @@  import Control.Applicative (Alternative (..)) import Control.Monad (MonadPlus (..))-import Data.Type.Equality (type (~~))+-- import Data.Type.Equality (type (~~))  -- | Wrap a non-indexed type constructor: newtype GWrapped (m :: * -> *) (p :: *) a = GWrapped { unG :: m a }@@ -30,12 +32,16 @@ liftG = GWrapped  instance Graphted (GWrapped m) where-    type Unit (GWrapped _) = ()-    type Inv (GWrapped _) i j = i ~~ j-    type Combine (GWrapped _) i j = i+    type Unit (GWrapped m) = ()+    type Inv (GWrapped m) i j = i ~ j+    type Combine (GWrapped m) i j = i  instance Applicative f => GPointed (GWrapped f) where+#if __GLASGOW_HASKELL__ >= 801     gpoint' = GWrapped . pure+#else+    gpoint = GWrapped . pure+#endif  instance Functor f => GFunctor (GWrapped f) where     gmap f = GWrapped . fmap f . unG
src/Data/Pointed/Graph.hs view
@@ -10,9 +10,15 @@  -} +{-# LANGUAGE CPP #-}+ {-# LANGUAGE PolyKinds            #-} {-# LANGUAGE ScopedTypeVariables  #-}++#if __GLASGOW_HASKELL__ >= 801 {-# LANGUAGE TypeApplications     #-}+#endif+ {-# LANGUAGE TypeFamilies         #-} {-# LANGUAGE UndecidableInstances #-} @@ -32,6 +38,9 @@     -- >>> :t gpoint @_ @(GWrapped Maybe) "Hello, World"     -- :: GWrapped Maybe () [Char]     gpoint :: forall a. a -> f (Pure f) a++-- This implementation will only work with type applications.+#if __GLASGOW_HASKELL__ >= 801     gpoint = gpoint' @p @f @(Pure f)      -- | Return a pointed functor indexed by a type 't' in the domain of 'p'.@@ -44,3 +53,4 @@     gpoint' :: forall t a. a -> f t a      {-# MINIMAL gpoint' #-}+#endif
src/Prelude/Graphted.hs view
@@ -10,7 +10,12 @@  -} +{-# LANGUAGE CPP #-}++#if __GLASGOW_HASKELL__ >= 801 {-# LANGUAGE ApplicativeDo         #-}+#endif+ {-# LANGUAGE FlexibleContexts      #-} {-# LANGUAGE GADTs                 #-} {-# LANGUAGE NoImplicitPrelude     #-}@@ -18,8 +23,6 @@ {-# LANGUAGE PolyKinds             #-} {-# LANGUAGE RebindableSyntax      #-} -{-# OPTIONS_GHC -Wno-partial-type-signatures #-}- module Prelude.Graphted (     -- Functor     fmap, (<$), (<$>),@@ -36,7 +39,9 @@     (<**>), liftA, liftA2, liftA3,     join, liftM, liftM2, liftM3, liftM4, liftM5, ap, +#if __GLASGOW_HASKELL__ >= 801     mapM_, sequence_,+#endif      module X     ) where@@ -64,13 +69,13 @@ pure :: GPointed f => a -> f (Pure f) a pure = gpoint -(<*>) :: (GApplicative f, _) => f i (a -> b) -> f j a -> f (Apply f i j) b+(<*>) :: (GApplicative f, Inv f i j) => f i (a -> b) -> f j a -> f (Apply f i j) b (<*>) = gap -(*>) :: (GApplicative f, _) => f i a -> f j b -> f (Then f i j) b+(*>) :: (GApplicative f, Inv f i j) => f i a -> f j b -> f (Then f i j) b (*>)= gthen -(<*) :: (GApplicative f, _) => f i a -> f j b -> f (But f i j) a+(<*) :: (GApplicative f, Inv f i j) => f i a -> f j b -> f (But f i j) a (<*) = gbut  return :: GPointed m => a -> m (Pure m) a@@ -88,20 +93,20 @@ fail :: GMonadFail m => String -> m (Fail m) a fail = gfail -(<+>) :: (GMonadPlus f, _) => f i a -> f j a -> f (Plus f i j) a+(<+>) :: (GMonadPlus f, Inv f i j) => f i a -> f j a -> f (Plus f i j) a (<+>) = gplus -(<|>) :: (GMonadOr f, _) => f i a -> f j a -> f (Or f i j) a+(<|>) :: (GMonadOr f, Inv f i j) => f i a -> f j a -> f (Or f i j) a (<|>) = gorelse  -- Simplified binding, what GHC.Base would like to do but cannot for backwards compatbility.-(>>) :: (GApplicative m, _) => m i a -> m j b -> m (Then m i j) b+(>>) :: (GApplicative m, Inv m i j) => m i a -> m j b -> m (Then m i j) b (>>) = gthen  join :: (GMonad m, Inv m i j) => m i (m j b) -> m (Join m i j) b join = gjoin -(<**>) :: (GApplicative f, _) => f i1 a -> f i2 (a -> b)+(<**>) :: (GApplicative f, Inv f (Pure f) i1, Inv f ((Apply f (Pure f) i1)) i2) => f i1 a -> f i2 (a -> b)        -> f (Apply f (Apply f (Pure f) i1) i2) b (<**>) = liftA2 (flip ($)) @@ -154,9 +159,15 @@        -> m (Apply m (Apply m (Apply m (Apply m (Fmap m i4) i3) i2) i1) i) b liftM5 f m1 m2 m3 m4 m5 = do { x1 <- m1; x2 <- m2; x3 <- m3; x4 <- m4; x5 <- m5; return (f x1 x2 x3 x4 x5) } +#if __GLASGOW_HASKELL__ >= 801 ap :: (GApplicative m, Inv m (Fmap m i) j) => m i (t -> b) -> m j t -> m (Apply m (Fmap m i) j) b ap m1 m2 = do { x1 <- m1; x2 <- m2; return (x1 x2) }+#else+-- ap :: (GApplicative m, Inv m (Fmap m i) j) => m i (t -> b) -> m j t -> m (Apply m (Fmap m i) j) b+ap m1 m2 = liftM m1 m2+#endif +#if __GLASGOW_HASKELL__ >= 801 -- Recursive bindings may be impossible. This type is inferred, but not always satisfiable. -- We will need to implement our own folds and control flow. mapM_ :: (GApplicative m, Foldable t, Apply m (Fmap m i) (Pure m) ~ Pure m, _)@@ -167,4 +178,4 @@ sequence_ :: (GApplicative m, Foldable t, Apply m (Fmap m i) (Pure m) ~ Pure m, _)           => t (m i a) -> m (Pure m) () sequence_ = foldr (>>) (return ())-+#endif