forbidden-fruit-0.1.0: A library accelerates imperative style programming.

Copyright(C) 2015, Yu Fukuzawa
LicenseBSD3
Maintainerminpou.primer@email.com
Stabilityexperimental
Portabilityportable
Safe HaskellNone
LanguageHaskell2010

Control.Imperative

Contents

Description

 

Synopsis

Documentation

var :: MonadVar m => a -> m (Ref (BaseEff m) a) Source

Create a new mutable variable.

val :: Monad m => a -> Ref m a Source

Wrap a value inside an immutable Ref.

ref :: MonadBase (BaseEff m) m => Ref (BaseEff m) a -> m a Source

Get a stored value from the Ref.

assign :: MonadBase (BaseEff m) m => Ref (BaseEff m) a -> a -> m () Source

Assign a value to the Ref.

(=:) :: MonadBase (BaseEff m) m => Ref (BaseEff m) a -> Ref (BaseEff m) a -> m () infix 2 Source

An assignment operator.

type MonadImperative m = (MonadVar m, MonadVector m, MonadHash m) Source

Useful constraint synonym.

type family BaseEff m :: * -> * Source

Instances

type BaseEff [] = [] 
type BaseEff IO = IO 
type BaseEff Maybe = Maybe 
type BaseEff Identity = Identity 
type BaseEff (Either e) = Either e 
type BaseEff (ST s) = ST s 
type BaseEff (ST s) = ST s 
type BaseEff (MaybeT m) = BaseEff m 
type BaseEff (ListT m) = BaseEff m 
type BaseEff (IdentityT m) = BaseEff m 
type BaseEff (WriterT w m) = BaseEff m 
type BaseEff (WriterT w m) = BaseEff m 
type BaseEff (ExceptT e m) = BaseEff m 
type BaseEff (StateT s m) = BaseEff m 
type BaseEff (StateT s m) = BaseEff m 
type BaseEff (ReaderT r m) = BaseEff m 
type BaseEff (ContT r m) = BaseEff m 
type BaseEff (LoopT c e m) = BaseEff m 
type BaseEff (RWST r w s m) = BaseEff m 
type BaseEff (RWST r w s m) = BaseEff m 

class Indexable v where Source

Indexing for array-like.

Associated Types

type Element v Source

type IndexType v Source

Methods

(!) :: v -> IndexType v -> Element v infixl 9 Source

Instances

PrimMonad m => Indexable (Ref m (Vector m (S (S n)) a)) 
(VectorElem a, PrimMonad m) => Indexable (Ref m (Vector m (S Z) a)) 
PrimMonad m => Indexable (Ref m (Vector m (S (S n)) a)) 
(VectorElem a, PrimMonad m) => Indexable (Ref m (Vector m (S Z) a)) 
PrimMonad m => Indexable (Vector m (S (S n)) a) 
(VectorElem a, PrimMonad m) => Indexable (Vector m (S Z) a) 
PrimMonad m => Indexable (Vector m (S (S n)) a) 
(VectorElem a, PrimMonad m) => Indexable (Vector m (S Z) a) 
(HashKey k, MHash m) => Indexable (HashTable m k v) 

Control Structures

whenR :: MonadBase (BaseEff m) m => Ref (BaseEff m) Bool -> m () -> m () Source

A when statement for Ref.

unlessR :: MonadBase (BaseEff m) m => Ref (BaseEff m) Bool -> m () -> m () Source

A unless statement for Ref.

ifR :: MonadBase (BaseEff m) m => Ref (BaseEff m) Bool -> m a -> m a -> m a Source

A if statement for Ref

whileR :: MonadBase (BaseEff m) m => Ref (BaseEff m) Bool -> LoopT c () m c -> m () Source

A while loop statement for Ref.

untilR :: MonadBase (BaseEff m) m => Ref (BaseEff m) Bool -> LoopT c () m c -> m () Source

A until loop statement for Ref.

doWhileR :: MonadBase (BaseEff m) m => LoopT a a m a -> Ref (BaseEff m) Bool -> m a Source

A do-while loop statement for Ref.

Types

data Ref m a Source

A reference type in the specified monad.

Instances

(Floating a, Monad m) => Floating (Ref m a) 
(Fractional a, Monad m) => Fractional (Ref m a) 
(Num a, Monad m) => Num (Ref m a) 
(IsString a, Monad m) => IsString (Ref m a) 
(Monoid w, Monad m) => Monoid (Ref m w) 
PrimMonad m => Indexable (Ref m (Vector m (S (S n)) a)) 
(VectorElem a, PrimMonad m) => Indexable (Ref m (Vector m (S Z) a)) 
PrimMonad m => Indexable (Ref m (Vector m (S (S n)) a)) 
(VectorElem a, PrimMonad m) => Indexable (Ref m (Vector m (S Z) a)) 
Monad m => HasVector (Ref m (Vector m n a)) (Vector m n a) m 
Monad m => HasVector (Ref m (Vector m n a)) (Vector m n a) m 
type Element (Ref m (Vector m (S (S n)) a)) = Ref m (Vector m (S n) a) 
type Element (Ref m (Vector m (S Z) a)) = Ref m a 
type Element (Ref m (Vector m (S (S n)) a)) = Ref m (Vector m (S n) a) 
type Element (Ref m (Vector m (S Z) a)) = Ref m a 
type IndexType (Ref m (Vector m (S (S n)) a)) = Int 
type IndexType (Ref m (Vector m (S Z) a)) = Int 
type IndexType (Ref m (Vector m (S (S n)) a)) = Int 
type IndexType (Ref m (Vector m (S Z) a)) = Int 

data Size n where Source

A sized-list type for specify the size of array.

Constructors

One :: Size Z 
(:*:) :: !Int -> Size n -> Size (S n) infixr 5 

dim2 :: Dim (S (S Z)) Source

dim3 :: Dim (S (S (S Z))) Source

Re-exports