biegunka-0.2: DSL definitions, interpreters, templating, git support

Safe HaskellNone

Control.Biegunka.Script.Token

Contents

Description

Infinite stream of unique tokens monad transformer

Synopsis

Types

Monad

data StreamT e m a Source

Monad transformer for the never ending stream of stuff

Instances

(Monad m, MonadState s m) => MonadState s (StreamT e m) 
(Monad m, MonadReader r m) => MonadReader r (StreamT e m) 
(~ Bool (IsToken e) True, Monad m) => MonadStream e (StreamT e m) 
MonadTrans (StreamT e) 
Monad m => Monad (StreamT e m) 
Monad m => Functor (StreamT e m) 
Monad m => Applicative (StreamT e m) 

mtl-style class

class Monad m => MonadStream e m | m -> e whereSource

mtl-style class, to avoid manual lifting

Methods

next :: m eSource

Get next element from the stream; advance that stream by one step

peek :: m eSource

Take a look at the next stream element, without modifying the stream

Instances

(Functor m, MonadStream e m) => MonadStream e (Free m) 
(Monad m, MonadStream e m) => MonadStream e (StateT s m) 
(Monad m, MonadStream e m) => MonadStream e (ReaderT r m) 
(~ Bool (IsToken e) True, Monad m) => MonadStream e (StreamT e m) 

Token stream

data Infinite a Source

Never ending stream of stuff

Constructors

a :< (Infinite a) 

Instances

Functor Infinite 
Eq a => Eq (Infinite a) 
Ord a => Ord (Infinite a) 
Show a => Show (Infinite a) 

data Token Source

Token.

Supposedly, the only way to get tokens is using tokens, so they are somewhat unique

Do things with StreamT

runStreamT :: Monad m => Infinite e -> StreamT e m a -> m aSource

Run StreamT with the supplied stream.

>>> runStreamT (fromList (map Token [1..])) (replicateM 3 next)
[Token 1,Token 2,Token 3]

mapStreamT :: (m (Infinite e, a) -> n (Infinite e, b)) -> StreamT e m a -> StreamT e n bSource

Map both the value and underlying monad

Tokens

tokens :: Infinite TokenSource

Infinite stream of tokens

noTokens :: Infinite VoidSource

Infinite stream of nothing, very zen

fromList :: [a] -> Infinite aSource

Get Infinite stream from list

>>> fromList [1,2,3]
1 :< (2 :< (3 :< *** Exception: Control.Biegunka.Script.Token.fromList: supplied list is not infinite