representable-tries 2.2.1 → 2.4
raw patch · 4 files changed
+24/−24 lines, 4 filesdep ~adjunctionsdep ~representable-functors
Dependency ranges changed: adjunctions, representable-functors
Files
- Data/Functor/Representable/Trie.hs +3/−3
- Data/Functor/Representable/Trie/Either.hs +4/−4
- Data/Functor/Representable/Trie/List.hs +14/−14
- representable-tries.cabal +3/−3
Data/Functor/Representable/Trie.hs view
@@ -195,13 +195,13 @@ showsPrec d = showsPrec d . toKeyedList instance HasTrie a => Apply ((:->:) a) where- Trie f <.> Trie g = Trie (f <.> g)+ (<.>) = apRep a <. _ = a _ .> b = b instance HasTrie a => Applicative ((:->:) a) where- pure a = Trie (pure a)- Trie f <*> Trie g = Trie (f <*> g)+ pure a = Trie (pureRep a)+ (<*>) = apRep a <* _ = a _ *> b = b
Data/Functor/Representable/Trie/Either.hs view
@@ -37,7 +37,7 @@ left :: EitherTrie f g a -> f a left (EitherTrie f _) = f -right :: EitherTrie f g a -> g a +right :: EitherTrie f g a -> g a right (EitherTrie _ g) = g instance (Apply f, Apply g, Semigroup s) => Semigroup (EitherTrie f g s) where@@ -46,7 +46,7 @@ instance (Applicative f, Applicative g, Monoid a) => Monoid (EitherTrie f g a) where mempty = EitherTrie (pure mempty) (pure mempty) EitherTrie a b `mappend` EitherTrie c d = EitherTrie (mappend <$> a <*> c) (mappend <$> b <*> d)- + instance (Functor f, Functor g) => Functor (EitherTrie f g) where fmap f (EitherTrie fs gs) = EitherTrie (fmap f fs) (fmap f gs) b <$ EitherTrie fs gs = EitherTrie (b <$ fs) (b <$ gs)@@ -63,11 +63,11 @@ _ *> b = b -- the direct implementation in terms of Bind is inefficient, using bindRep instead-instance (Representable f, Representable g) => Bind (EitherTrie f g) where+instance (Apply f, Representable f, Apply g, Representable g) => Bind (EitherTrie f g) where (>>-) = bindRep instance (Representable f, Representable g) => Monad (EitherTrie f g) where- return = pure+ return = pureRep (>>=) = bindRep _ >> a = a
Data/Functor/Representable/Trie/List.hs view
@@ -4,14 +4,14 @@ -- Module : Data.Functor.Representable.Trie.List -- Copyright : (c) Edward Kmett 2011 -- License : BSD3--- +-- -- Maintainer : ekmett@gmail.com -- Stability : experimental--- +-- ---------------------------------------------------------------------- -module Data.Functor.Representable.Trie.List ( - ListTrie (..) +module Data.Functor.Representable.Trie.List (+ ListTrie (..) , nil , cons ) where@@ -28,7 +28,7 @@ import Data.Key import Prelude hiding (lookup,zipWith) --- the f-branching stream comonad is the trie of a list +-- the f-branching stream comonad is the trie of a list data ListTrie f a = ListTrie a (f (ListTrie f a)) -- deriving (Eq,Ord,Show,Read) type instance Key (ListTrie f) = [Key f]@@ -36,21 +36,21 @@ nil :: ListTrie f a -> a nil (ListTrie x _) = x -cons :: Indexable f => Key f -> ListTrie f a -> ListTrie f a -cons a (ListTrie _ xs) = index xs a +cons :: Indexable f => Key f -> ListTrie f a -> ListTrie f a+cons a (ListTrie _ xs) = index xs a instance Functor f => Functor (ListTrie f) where fmap f (ListTrie a as) = ListTrie (f a) (fmap (fmap f) as) -- b <$ _ = pure b -instance Apply f => Apply (ListTrie f) where- ListTrie a as <.> ListTrie b bs = ListTrie (a b) ((<.>) <$> as <.> bs)+instance Representable f => Apply (ListTrie f) where+ (<.>) = apRep a <. _ = a _ .> b = b -instance Applicative f => Applicative (ListTrie f) where- pure a = as where as = ListTrie a (pure as)- ListTrie a as <*> ListTrie b bs = ListTrie (a b) ((<*>) <$> as <*> bs)+instance Representable f => Applicative (ListTrie f) where+ pure a = as where as = ListTrie a (pureRep as)+ (<*>) = apRep a <* _ = a _ *> b = b @@ -58,7 +58,7 @@ (>>-) = bindRep instance Representable f => Monad (ListTrie f) where- return = pure+ return a = as where as = ListTrie a (pureRep as) (>>=) = bindRep _ >> a = a @@ -99,7 +99,7 @@ distribute = distributeRep instance Indexable f => Indexable (ListTrie f) where- index (ListTrie x _) [] = x + index (ListTrie x _) [] = x index (ListTrie _ xs) (a:as) = index (index xs a) as instance Adjustable f => Adjustable (ListTrie f) where
representable-tries.cabal view
@@ -1,6 +1,6 @@ name: representable-tries category: Data Structures, Functors, Monads, Comonads-version: 2.2.1+version: 2.4 license: BSD3 cabal-version: >= 1.6 license-file: LICENSE@@ -43,8 +43,8 @@ semigroupoids >= 1.3.1 && < 1.4, keys >= 2.1.3 && < 2.2, comonad-transformers >= 2.1.1 && < 2.2,- adjunctions >= 2.2.1 && < 2.3,- representable-functors >= 2.2.1 && < 2.3+ adjunctions >= 2.4 && < 2.5,+ representable-functors >= 2.4 && < 2.5 exposed-modules: Control.Monad.Reader.Trie