-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Some utilities every serious chatty-based application may need. -- -- Some utilities every serious chatty-based application may need. -- Includes a graph type, search trees, a None class, a counter and an -- atom store. Note that the author does not recommend usage in new -- projects any more. Please use packages that are better suited for your -- individual need. @package chatty-utils @version 0.7.3.4 -- | Provides a typeclass for everything that may carry a void value module Data.Chatty.None -- | Typeclass for everything that may carry a void value class None n none :: None n => n -- | Wrap the void into a monad. noneM :: (Monad m, None n) => m n -- | Join a maybe into the underlying type. Nothing becomes -- none. joinMaybe :: None n => Maybe n -> n -- | Wrap the value into a maybe. none becomes Nothing. expandMaybe :: (Eq n, None n) => n -> Maybe n -- | Clean the maybe by pulling wrapped nones to the outside (as a -- Nothing). cleanMaybe :: (Eq n, None n) => Maybe n -> Maybe n -- | Eliminate all void elements from the list. reduce :: (Eq n, None n) => [n] -> [n] -- | Eliminate all Nothings from the list and unjust all remaining -- values. reduceMaybe :: [Maybe a] -> [a] instance Data.Chatty.None.None [a] instance Data.Chatty.None.None (GHC.Base.Maybe a) instance Data.Chatty.None.None () instance Data.Chatty.None.None Data.Text.Internal.Text instance Data.Chatty.None.None (a -> a) instance GHC.Base.Monad m => Data.Chatty.None.None (a -> m a) instance Data.Chatty.None.None GHC.Types.Int instance Data.Chatty.None.None GHC.Integer.Type.Integer instance Data.Chatty.None.None GHC.Types.Bool -- | Provides a ternary search trie module Data.Chatty.TST -- | A ternary search trie data TST a EmptyTST :: TST a TST :: Char -> (Maybe a) -> (TST a) -> (TST a) -> (TST a) -> TST a -- | Insert something into the TST tstInsert :: String -> a -> TST a -> TST a -- | Lookup some string in the TST tstLookup :: String -> TST a -> Maybe a -- | Check if the TST contains the given key tstContains :: String -> TST a -> Bool -- | Traverse TST tstTraverse :: TST a -> [(String, a)] instance Data.Chatty.None.None (Data.Chatty.TST.TST a) module Data.Chatty.ListBuilder class Monad l => ListBuilder l i | l -> i li :: ListBuilder l i => i -> l () buildList :: ListBuilder l i => l () -> [i] newtype StrictBuilderT i m a StrictBuilder :: ([i] -> m (a, [i])) -> StrictBuilderT i m a [runStrictBuilderT] :: StrictBuilderT i m a -> [i] -> m (a, [i]) type StrictBuilder i = StrictBuilderT i Identity strictBuild :: StrictBuilderT i Identity () -> [i] newtype LazyBuilderT i m a LazyBuilder :: (([i] -> [i]) -> m (a, [i] -> [i])) -> LazyBuilderT i m a [runLazyBuilderT] :: LazyBuilderT i m a -> ([i] -> [i]) -> m (a, [i] -> [i]) type LazyBuilder i = LazyBuilderT i Identity lazyBuild :: LazyBuilderT i Identity () -> [i] lis :: ListBuilder l i => [i] -> l () lit :: ListBuilder l (a, b) => a -> b -> l () (>-<) :: ListBuilder l (a, b) => a -> b -> l () instance GHC.Base.Functor m => GHC.Base.Functor (Data.Chatty.ListBuilder.StrictBuilderT i m) instance (GHC.Base.Functor m, GHC.Base.Monad m) => GHC.Base.Applicative (Data.Chatty.ListBuilder.StrictBuilderT i m) instance GHC.Base.Monad m => GHC.Base.Monad (Data.Chatty.ListBuilder.StrictBuilderT i m) instance Control.Monad.Trans.Class.MonadTrans (Data.Chatty.ListBuilder.StrictBuilderT i) instance Data.Chatty.ListBuilder.ListBuilder (Data.Chatty.ListBuilder.StrictBuilder i) i instance GHC.Base.Functor m => GHC.Base.Functor (Data.Chatty.ListBuilder.LazyBuilderT i m) instance (GHC.Base.Functor m, GHC.Base.Monad m) => GHC.Base.Applicative (Data.Chatty.ListBuilder.LazyBuilderT i m) instance GHC.Base.Monad m => GHC.Base.Monad (Data.Chatty.ListBuilder.LazyBuilderT i m) instance Control.Monad.Trans.Class.MonadTrans (Data.Chatty.ListBuilder.LazyBuilderT i) instance Data.Chatty.ListBuilder.ListBuilder (Data.Chatty.ListBuilder.LazyBuilder i) i module Data.Chatty.Hetero -- | The Cons type for a heterogenous list data Cons a b (:-:) :: a -> b -> Cons a b -- | The empty list data Nil Nil :: Nil -- | Typeclass for appending one heterogenous list to another one class Append a b ab | a b -> ab tappend :: Append a b ab => a -> b -> ab -- | Typeclass for wrapping a heterogenous list into a Maybe on demand class IntoMaybe a ar | a -> ar tjust :: IntoMaybe a ar => a -> ar tnothing :: IntoMaybe a ar => a -> ar -- | Typeclass for everything that may be converted to a tuple class Tuplify l t | l -> t tuplify :: Tuplify l t => l -> t data Titled a Titled :: String -> a -> Titled a instance Data.Chatty.Hetero.Append Data.Chatty.Hetero.Nil b b instance Data.Chatty.Hetero.Append b c bc => Data.Chatty.Hetero.Append (Data.Chatty.Hetero.Cons a b) c (Data.Chatty.Hetero.Cons a bc) instance Data.Chatty.Hetero.IntoMaybe Data.Chatty.Hetero.Nil Data.Chatty.Hetero.Nil instance Data.Chatty.Hetero.IntoMaybe (Data.Chatty.Hetero.Cons a as) (Data.Chatty.Hetero.Cons (GHC.Base.Maybe (Data.Chatty.Hetero.Cons a as)) Data.Chatty.Hetero.Nil) instance Data.Chatty.Hetero.Tuplify Data.Chatty.Hetero.Nil () instance Data.Chatty.Hetero.Tuplify a ar => Data.Chatty.Hetero.Tuplify (Data.Chatty.Hetero.Cons a Data.Chatty.Hetero.Nil) ar instance (Data.Chatty.Hetero.Tuplify a ar, Data.Chatty.Hetero.Tuplify b br) => Data.Chatty.Hetero.Tuplify (Data.Chatty.Hetero.Cons a (Data.Chatty.Hetero.Cons b Data.Chatty.Hetero.Nil)) (ar, br) instance (Data.Chatty.Hetero.Tuplify a ar, Data.Chatty.Hetero.Tuplify b br, Data.Chatty.Hetero.Tuplify c cr) => Data.Chatty.Hetero.Tuplify (Data.Chatty.Hetero.Cons a (Data.Chatty.Hetero.Cons b (Data.Chatty.Hetero.Cons c Data.Chatty.Hetero.Nil))) (ar, br, cr) instance (Data.Chatty.Hetero.Tuplify a ar, Data.Chatty.Hetero.Tuplify b br, Data.Chatty.Hetero.Tuplify c cr, Data.Chatty.Hetero.Tuplify d dr) => Data.Chatty.Hetero.Tuplify (Data.Chatty.Hetero.Cons a (Data.Chatty.Hetero.Cons b (Data.Chatty.Hetero.Cons c (Data.Chatty.Hetero.Cons d Data.Chatty.Hetero.Nil)))) (ar, br, cr, dr) instance (Data.Chatty.Hetero.Tuplify a ar, Data.Chatty.Hetero.Tuplify b br, Data.Chatty.Hetero.Tuplify c cr, Data.Chatty.Hetero.Tuplify d dr, Data.Chatty.Hetero.Tuplify e er) => Data.Chatty.Hetero.Tuplify (Data.Chatty.Hetero.Cons a (Data.Chatty.Hetero.Cons b (Data.Chatty.Hetero.Cons c (Data.Chatty.Hetero.Cons d (Data.Chatty.Hetero.Cons e Data.Chatty.Hetero.Nil))))) (ar, br, cr, dr, er) instance (Data.Chatty.Hetero.Tuplify a ar, Data.Chatty.Hetero.Tuplify b br, Data.Chatty.Hetero.Tuplify c cr, Data.Chatty.Hetero.Tuplify d dr, Data.Chatty.Hetero.Tuplify e er, Data.Chatty.Hetero.Tuplify f fr) => Data.Chatty.Hetero.Tuplify (Data.Chatty.Hetero.Cons a (Data.Chatty.Hetero.Cons b (Data.Chatty.Hetero.Cons c (Data.Chatty.Hetero.Cons d (Data.Chatty.Hetero.Cons e (Data.Chatty.Hetero.Cons f Data.Chatty.Hetero.Nil)))))) (ar, br, cr, dr, er, fr) instance Data.Chatty.Hetero.Tuplify GHC.Types.Int GHC.Types.Int instance Data.Chatty.Hetero.Tuplify GHC.Types.Char GHC.Types.Char instance Data.Chatty.Hetero.Tuplify a ar => Data.Chatty.Hetero.Tuplify [a] [ar] instance Data.Chatty.Hetero.Tuplify a ar => Data.Chatty.Hetero.Tuplify (GHC.Base.Maybe a) (GHC.Base.Maybe ar) instance Data.Chatty.Hetero.Tuplify a ar => Data.Chatty.Hetero.Tuplify (Data.Chatty.Hetero.Titled a) ar -- | Provides a monad for error handling. Okay, I confess it's equal to -- ErrorT... You should use that one. module Data.Chatty.Fail -- | The error handling monad. newtype FailT e m a Fail :: m (Either e a) -> FailT e m a [runFailT] :: FailT e m a -> m (Either e a) type Fail e = FailT e Identity instance GHC.Base.Monad m => GHC.Base.Functor (Data.Chatty.Fail.FailT e m) instance GHC.Base.Monad m => GHC.Base.Applicative (Data.Chatty.Fail.FailT e m) instance GHC.Base.Monad m => GHC.Base.Monad (Data.Chatty.Fail.FailT e m) instance Control.Monad.Trans.Class.MonadTrans (Data.Chatty.Fail.FailT e) instance GHC.Base.Monad m => Control.Monad.Error.Class.MonadError e (Data.Chatty.Fail.FailT e m) -- | Provides a counter monad. module Data.Chatty.Counter -- | A counter monad. newtype CounterT m a Counter :: (Int -> m (a, Int)) -> CounterT m a [runCounterT] :: CounterT m a -> Int -> m (a, Int) -- | Typeclass for all counter monads. class Monad m => ChCounter m -- | Tell the current number and increment it countOn :: ChCounter m => m Int -- | Run the given function inside a counter withCounter :: (Monad m, Functor m) => CounterT m a -> m a instance GHC.Base.Functor m => GHC.Base.Functor (Data.Chatty.Counter.CounterT m) instance (GHC.Base.Functor m, GHC.Base.Monad m) => GHC.Base.Applicative (Data.Chatty.Counter.CounterT m) instance GHC.Base.Monad m => GHC.Base.Monad (Data.Chatty.Counter.CounterT m) instance Control.Monad.Trans.Class.MonadTrans Data.Chatty.Counter.CounterT instance GHC.Base.Monad m => Data.Chatty.Counter.ChCounter (Data.Chatty.Counter.CounterT m) -- | Provides a typeclass for all binary search trees and an unbalanced -- implementation module Data.Chatty.BST -- | Only instances of Indexable may be saved in a BST class Ord o => Indexable i o v | i -> o, i -> v -- | Extract the index indexOf :: Indexable i o v => i -> o -- | Extract the value valueOf :: Indexable i o v => i -> v -- | Typeclass for all BSTs that store the given Indexable class Indexable i o v => AnyBST t i o v -- | Insert into the tree anyBstInsert :: AnyBST t i o v => i -> t i -> t i -- | Remove from the tree anyBstRemove :: AnyBST t i o v => o -> t i -> t i -- | Get the greatest element anyBstMax :: AnyBST t i o v => t i -> Maybe i -- | Get the least element anyBstMin :: AnyBST t i o v => t i -> Maybe i -- | Lookup a given key anyBstLookup :: AnyBST t i o v => o -> t i -> Maybe v -- | An empty tree anyBstEmpty :: AnyBST t i o v => t i -- | The root of the tree anyBstHead :: AnyBST t i o v => t i -> Maybe i -- | Traverse the tree in order anyBstInorder :: AnyBST t i o v => t i -> [i] -- | An unbalanced binary search tree data BST a EmptyBST :: BST a BST :: a -> !(BST a) -> !(BST a) -> BST a -- | Insert into the BST bstInsert :: Indexable i o v => i -> BST i -> BST i -- | Remove from the BST bstRemove :: Indexable i o v => o -> BST i -> BST i -- | Get the greatest element bstMax :: BST i -> Maybe i -- | Get the least element bstMin :: BST i -> Maybe i -- | Lookup a given key bstLookup :: Indexable i o v => o -> BST i -> Maybe v -- | Lookup if a given key is contained bstContains :: Indexable i o v => o -> BST i -> Bool -- | Return the tree's root bstHead :: Indexable i o v => BST i -> Maybe i -- | Traverse the tree in order bstInorder :: Indexable i o v => BST i -> [i] instance Data.Chatty.BST.Indexable GHC.Types.Int GHC.Types.Int GHC.Types.Int instance GHC.Classes.Ord o => Data.Chatty.BST.Indexable (o, a) o a instance GHC.Classes.Ord o => Data.Chatty.BST.Indexable (o, a, b) o (a, b) instance GHC.Classes.Ord o => Data.Chatty.BST.Indexable (o, a, b, c) o (a, b, c) instance GHC.Classes.Ord o => Data.Chatty.BST.Indexable (o, a, b, c, d) o (a, b, c, d) instance GHC.Classes.Ord o => Data.Chatty.BST.Indexable (o, a, b, c, d, e) o (a, b, c, d, e) instance Data.Chatty.BST.Indexable i o v => Data.Chatty.BST.AnyBST Data.Chatty.BST.BST i o v instance Data.Chatty.None.None (Data.Chatty.BST.BST a) -- | Provides an unbalanced BST with a focus on the root. module Data.Chatty.Focus -- | An unbalanced BST with a focus on the root. data Focus a -- | Rotate the tree such that the given element becomes the root node. focusSelect :: Indexable a o v => o -> Focus a -> Maybe (Focus a) instance Data.Chatty.None.None (Data.Chatty.Focus.Focus a) instance Data.Chatty.BST.Indexable i o v => Data.Chatty.BST.AnyBST Data.Chatty.Focus.Focus i o v -- | Provides an AVL tree. module Data.Chatty.AVL -- | Get the greatest element. avlMax :: AVL i -> Maybe i -- | Get the least element. avlMin :: AVL i -> Maybe i -- | Lookup a given key. avlLookup :: Indexable i o v => o -> AVL i -> Maybe v -- | Get the height of the tree. avlHeight :: AVL i -> Int -- | Get the size of the tree. avlSize :: AVL i -> Int -- | Insert into the tree. avlInsert :: Indexable i o v => i -> AVL i -> AVL i -- | Remove from the tree. avlRemove :: Indexable i o v => o -> AVL i -> AVL i -- | An AVL tree. data AVL a EmptyAVL :: AVL a AVL :: a -> Int -> Int -> !(AVL a) -> !(AVL a) -> AVL a -- | Get the root of the tree. avlRoot :: AVL i -> i -- | Traverse the tree, order (head, left, right) avlPreorder :: AVL i -> [i] -- | Traverse the tree, order (left, right, head) avlPostorder :: AVL i -> [i] -- | Traverse the tree, order (left, head, right) avlInorder :: AVL i -> [i] instance Data.Chatty.BST.Indexable i o v => Data.Chatty.BST.AnyBST Data.Chatty.AVL.AVL i o v instance Data.Chatty.None.None (Data.Chatty.AVL.AVL a) instance GHC.Base.Functor Data.Chatty.AVL.AVL -- | Provides a variable-storing monad and functions for access. Not -- recommended. Use IORef, STRef or the like. Really. module Data.Chatty.Atoms -- | Phantom type for atom IDs data Atom a Atom :: Int -> Atom a FunAtom :: Int -> (Atom b) -> (b -> a) -> (b -> a -> b) -> Atom a FunAtom2 :: Int -> (Atom b) -> (Atom c) -> ((b, c) -> a) -> ((b, c) -> a -> (b, c)) -> Atom a newtype Container Container :: () -> Container -- | The storage monad newtype AtomStoreT m a AtomStore :: (AVL (Int, Container) -> m (a, AVL (Int, Container))) -> AtomStoreT m a [runAtomStoreT] :: AtomStoreT m a -> AVL (Int, Container) -> m (a, AVL (Int, Container)) -- | Typeclass for all atom-storing monads. class ChCounter m => ChAtoms m where newAtom = liftM Atom countOn funAtom b r p = do { i <- countOn; return $ FunAtom i b r p } funAtom2 b c r p = do { i <- countOn; return $ FunAtom2 i b c r p } cloneAtom a = do { b <- newAtom; v <- getAtom a; putAtom b v; return b } -- | Reserve a new atom. newAtom :: ChAtoms m => m (Atom v) -- | Construct a new functional atom. funAtom :: ChAtoms m => Atom b -> (b -> a) -> (b -> a -> b) -> m (Atom a) -- | Construct a new doubly-source functional atom funAtom2 :: ChAtoms m => Atom b -> Atom c -> ((b, c) -> a) -> ((b, c) -> a -> (b, c)) -> m (Atom a) -- | Save a value for the given atom. putAtom :: ChAtoms m => Atom v -> v -> m () -- | Get the value from a given atom. getAtom :: ChAtoms m => Atom v -> m v -- | Dispose the given atom. dispAtom :: ChAtoms m => Atom v -> m () -- | Clone the given atom. cloneAtom :: ChAtoms m => Atom v -> m (Atom v) -- | Run a pure function on atoms. mapAtom :: ChAtoms m => (a -> a) -> Atom a -> m () -- | Arrow type operating on atoms. Works by cloning the educt, then -- overwriting the clone. You shouldn't use this inside long-term -- environments, as massive usage blows up the memory. newtype Redundant m a b Redundant :: (Atom a -> m (Atom b)) -> Redundant m a b [runRedundant] :: Redundant m a b -> Atom a -> m (Atom b) instance GHC.Classes.Eq (Data.Chatty.Atoms.Atom a) instance GHC.Classes.Ord (Data.Chatty.Atoms.Atom a) instance GHC.Base.Functor m => GHC.Base.Functor (Data.Chatty.Atoms.AtomStoreT m) instance (GHC.Base.Functor m, GHC.Base.Monad m) => GHC.Base.Applicative (Data.Chatty.Atoms.AtomStoreT m) instance GHC.Base.Monad m => GHC.Base.Monad (Data.Chatty.Atoms.AtomStoreT m) instance Control.Monad.Trans.Class.MonadTrans Data.Chatty.Atoms.AtomStoreT instance Control.Monad.IO.Class.MonadIO m => Control.Monad.IO.Class.MonadIO (Data.Chatty.Atoms.AtomStoreT m) instance Data.Chatty.Counter.ChCounter m => Data.Chatty.Counter.ChCounter (Data.Chatty.Atoms.AtomStoreT m) instance Data.Chatty.Counter.ChCounter m => Data.Chatty.Atoms.ChAtoms (Data.Chatty.Atoms.AtomStoreT m) instance Data.Chatty.Atoms.ChAtoms m => Control.Category.Category (Data.Chatty.Atoms.Redundant m) instance Data.Chatty.Atoms.ChAtoms m => Control.Arrow.Arrow (Data.Chatty.Atoms.Redundant m) -- | Provides a general graph. module Data.Chatty.Graph -- | Phantom type for a node ID newtype NodeId NodeId :: Int -> NodeId -- | A general graph data Graph a b c Graph :: AVL (Node a) -> [Edge b c] -> NodeId -> Graph a b c [nodes] :: Graph a b c -> AVL (Node a) [edges] :: Graph a b c -> [Edge b c] [nextId] :: Graph a b c -> NodeId -- | A node for the graph data Node a Node :: Bool -> a -> NodeId -> Node a [nodeMarked] :: Node a -> Bool [nodeContent] :: Node a -> a [nodeId] :: Node a -> NodeId -- | An edge for the graph data Edge b c Edge :: NodeId -> NodeId -> Int -> b -> c -> Edge b c [fromNode] :: Edge b c -> NodeId [toNode] :: Edge b c -> NodeId [weight] :: Edge b c -> Int [label] :: Edge b c -> b [content] :: Edge b c -> c -- | Increment a NodeId incId :: NodeId -> NodeId -- | An empty graph emptyGraph :: Graph a b c -- | Add a node to the graph addNode :: a -> Graph a b c -> Graph a b c -- | Add a node to the graph and also return its ID addNode' :: a -> Graph a b c -> (NodeId, Graph a b c) -- | Add a bunch of nodes addNodes :: [a] -> Graph a b c -> Graph a b c -- | Add a bunch of nodes and also return their IDs addNodes' :: [a] -> Graph a b c -> ([NodeId], Graph a b c) -- | Return all nodes allNodes :: Graph a b c -> [Node a] -- | Return the node in the AVL tree's root rootNode :: Graph a b c -> NodeId -- | Add a unidirectional edge to the graph (provide both nodes, a weight -- and a label) addEdge :: NodeId -> NodeId -> Int -> b -> c -> Graph a b c -> Graph a b c -- | Add a unidirectional edge to the graph (provide the Edge) addEdge' :: Edge b c -> Graph a b c -> Graph a b c -- | Add a bidirectional edge to the graph (provide both nodes, a weight -- and a label) addMutualEdge :: NodeId -> NodeId -> Int -> b -> c -> Graph a b c -> Graph a b c -- | Add a bunch of edges unidirectionally (provide both nodes, a weight -- and a label) addEdges :: [(NodeId, NodeId, Int, b, c)] -> Graph a b c -> Graph a b c -- | Add a bunch of edges unidirectionally (provide the Edges) addEdges' :: [Edge b c] -> Graph a b c -> Graph a b c -- | Add a bunch of edges bidirectionally (provide both nodes, a weight and -- a label) addMutualEdges :: [(NodeId, NodeId, Int, b, c)] -> Graph a b c -> Graph a b c -- | Get the node's content from its ID getNode :: NodeId -> Graph a b c -> a -- | Get the Node object from its ID getNode' :: NodeId -> Graph a b c -> Node a -- | Set the node's content by its ID setNode :: NodeId -> a -> Graph a b c -> Graph a b c -- | Mark a node by its ID markNode :: NodeId -> Graph a b c -> Graph a b c -- | Follow an edge by its source node and label followEdge :: Eq b => NodeId -> b -> Graph a b c -> Maybe NodeId -- | Query an edge's content queryEdge :: Eq b => NodeId -> b -> Graph a b c -> Maybe c -- | List all edges from the given node listEdges :: NodeId -> Graph a b c -> [(b, c, NodeId)] instance GHC.Classes.Ord Data.Chatty.Graph.NodeId instance GHC.Show.Show Data.Chatty.Graph.NodeId instance GHC.Classes.Eq Data.Chatty.Graph.NodeId instance Data.Chatty.BST.Indexable (Data.Chatty.Graph.Node a) Data.Chatty.Graph.NodeId (Data.Chatty.Graph.Node a) instance GHC.Show.Show a => GHC.Show.Show (Data.Chatty.Graph.Node a) instance GHC.Show.Show b => GHC.Show.Show (Data.Chatty.Graph.Edge b c) instance Data.Chatty.None.None (Data.Chatty.Graph.Graph a b c)