-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Type-threaded list -- -- Thrist is a list-like data structure (GADT) whose elements -- are values of a two-parameter datatype. The typing constraint ensures -- that the second type parameter of a former value unifies with the -- first type parameter of the latter. -- -- This threading of types is the foundation for thrists' nice -- properties. E.g., paired with a suitable semantics, function -- composition $(.)$ can be embedded. -- -- Technically a thrist is embodying the concept of a free -- category. -- -- Sub-modules demonstrate the power of the thrist idea by emulating some -- familiar data structures. -- -- For further ideas, please consult the companion (draft) paper -- "Thrists: Dominoes of Data" at -- https://github.com/ggreif/omega/blob/master/doc/Thrist-draft-2011-11-20.pdf @package thrist @version 0.4 module Data.Thrist -- | A type-threaded list of binary polymorphic types. data Thrist :: (k -> k -> *) -> k -> k -> * [Nil] :: Thrist arr a a [Cons] :: (a `arr` b) -> Thrist arr b c -> Thrist arr a c -- | A newtype wrapper, defined for convenience, that "swaps" the two type -- variables of a binary type. Can be used to reverse a Thrist using -- foldlThrist. See examples. newtype Flipped m a b Flipped :: m b a -> Flipped m a b [unflip] :: Flipped m a b -> m b a -- | Equivalent to map for thrists. Takes a function from one binary -- type to another and applies it to each thrist element. For example -- this could convert a thrist of (a,b) into a thrist of Either a b: mapThrist :: (forall i j. (i `brr` j) -> i `arr` j) -> Thrist brr a b -> Thrist arr a b -- | Equivalent to foldr for thrists. Takes a combining function, a -- value to replace Nil, and a thrist, returning some new binary type. foldrThrist :: (forall i j. (i `arr` j) -> (j `brr` c) -> i `brr` c) -> (b `brr` c) -> Thrist arr a b -> a `brr` c -- | Equivalent to foldl for Thrists. foldlThrist :: (forall j k. (a `brr` j) -> (j `arr` k) -> a `brr` k) -> (a `brr` b) -> Thrist arr b c -> a `brr` c -- | Equivalent to foldr1 for Thrists. foldr1Thrist :: (forall i j k. (i `arr` j) -> (j `arr` k) -> i `arr` k) -> Thrist arr a b -> a `arr` b -- | Equivalent to foldl1 for Thrists. foldl1Thrist :: (forall i j k. (i `arr` j) -> (j `arr` k) -> i `arr` k) -> Thrist arr a b -> a `arr` b -- | Equivalent to mapM on Thrists. mapMThrist :: Monad m => (forall i j. (i `brr` j) -> m (i `arr` j)) -> Thrist brr a b -> m (Thrist arr a b) -- | Equivalent to foldM on Thrists. foldMThrist :: Monad m => (forall j k. (a `brr` j) -> (j `arr` k) -> m (a `brr` k)) -> (a `brr` b) -> Thrist arr b c -> m (a `brr` c) -- | Equivalent to (++) for thrists. appendThrist :: Thrist arr a b -> Thrist arr b c -> Thrist arr a c -- | Returns True when the Thrist is Nil. nullThrist :: Thrist arr a b -> Bool -- | Returns the length of the Thrist. lengthThrist :: Thrist arr a b -> Int instance forall k (arr :: k -> k -> *) (a :: k). GHC.Base.Semigroup (Data.Thrist.Thrist arr a a) instance forall k (arr :: k -> k -> *) (a :: k). GHC.Base.Monoid (Data.Thrist.Thrist arr a a) instance Control.Arrow.Arrow arr => Control.Arrow.Arrow (Data.Thrist.Thrist arr) instance forall k (arr :: k -> k -> *). Control.Category.Category (Data.Thrist.Thrist arr) module Data.Thrist.List data List :: * -> * -> * [El] :: a -> List a a instance GHC.Base.Functor Data.Thrist.List.List' instance GHC.Base.Applicative Data.Thrist.List.List' instance GHC.Base.Monad Data.Thrist.List.List' module Data.Thrist.Monad data Monad' :: (* -> *) -> * -> * -> * [Feed] :: Monad m => m b -> Monad' m a b [Digest] :: Monad m => (a -> m b) -> Monad' m a b