neural-0.3.0.0: Neural Networks in native Haskell

Copyright(c) Lars Brünjes, 2016
LicenseMIT
Maintainerbrunjlar@gmail.com
Stabilityexperimental
Portabilityportable
Safe HaskellNone
LanguageHaskell2010

Data.MyPrelude

Description

This module simply reexports a selection of commonly used standard types and functions.

Synopsis

Documentation

class NFData a where #

A class of types that can be fully evaluated.

Since: 1.1.0.0

Minimal complete definition

Nothing

Instances

NFData Bool 

Methods

rnf :: Bool -> () #

NFData Char 

Methods

rnf :: Char -> () #

NFData Double 

Methods

rnf :: Double -> () #

NFData Float 

Methods

rnf :: Float -> () #

NFData Int 

Methods

rnf :: Int -> () #

NFData Int8 

Methods

rnf :: Int8 -> () #

NFData Int16 

Methods

rnf :: Int16 -> () #

NFData Int32 

Methods

rnf :: Int32 -> () #

NFData Int64 

Methods

rnf :: Int64 -> () #

NFData Integer 

Methods

rnf :: Integer -> () #

NFData Word 

Methods

rnf :: Word -> () #

NFData Word8 

Methods

rnf :: Word8 -> () #

NFData Word16 

Methods

rnf :: Word16 -> () #

NFData Word32 

Methods

rnf :: Word32 -> () #

NFData Word64 

Methods

rnf :: Word64 -> () #

NFData CallStack

Since: 1.4.2.0

Methods

rnf :: CallStack -> () #

NFData TypeRep

NOTE: Only defined for base-4.8.0.0 and later

Since: 1.4.0.0

Methods

rnf :: TypeRep -> () #

NFData () 

Methods

rnf :: () -> () #

NFData TyCon

NOTE: Only defined for base-4.8.0.0 and later

Since: 1.4.0.0

Methods

rnf :: TyCon -> () #

NFData ThreadId

Since: 1.4.0.0

Methods

rnf :: ThreadId -> () #

NFData Natural

Since: 1.4.0.0

Methods

rnf :: Natural -> () #

NFData Void

Defined as rnf = absurd.

Since: 1.4.0.0

Methods

rnf :: Void -> () #

NFData Version

Since: 1.3.0.0

Methods

rnf :: Version -> () #

NFData Unique

Since: 1.4.0.0

Methods

rnf :: Unique -> () #

NFData ExitCode

Since: 1.4.2.0

Methods

rnf :: ExitCode -> () #

NFData CChar

Since: 1.4.0.0

Methods

rnf :: CChar -> () #

NFData CSChar

Since: 1.4.0.0

Methods

rnf :: CSChar -> () #

NFData CUChar

Since: 1.4.0.0

Methods

rnf :: CUChar -> () #

NFData CShort

Since: 1.4.0.0

Methods

rnf :: CShort -> () #

NFData CUShort

Since: 1.4.0.0

Methods

rnf :: CUShort -> () #

NFData CInt

Since: 1.4.0.0

Methods

rnf :: CInt -> () #

NFData CUInt

Since: 1.4.0.0

Methods

rnf :: CUInt -> () #

NFData CLong

Since: 1.4.0.0

Methods

rnf :: CLong -> () #

NFData CULong

Since: 1.4.0.0

Methods

rnf :: CULong -> () #

NFData CLLong

Since: 1.4.0.0

Methods

rnf :: CLLong -> () #

NFData CULLong

Since: 1.4.0.0

Methods

rnf :: CULLong -> () #

NFData CFloat

Since: 1.4.0.0

Methods

rnf :: CFloat -> () #

NFData CDouble

Since: 1.4.0.0

Methods

rnf :: CDouble -> () #

NFData CPtrdiff

Since: 1.4.0.0

Methods

rnf :: CPtrdiff -> () #

NFData CSize

Since: 1.4.0.0

Methods

rnf :: CSize -> () #

NFData CWchar

Since: 1.4.0.0

Methods

rnf :: CWchar -> () #

NFData CSigAtomic

Since: 1.4.0.0

Methods

rnf :: CSigAtomic -> () #

NFData CClock

Since: 1.4.0.0

Methods

rnf :: CClock -> () #

NFData CTime

Since: 1.4.0.0

Methods

rnf :: CTime -> () #

NFData CUSeconds

Since: 1.4.0.0

Methods

rnf :: CUSeconds -> () #

NFData CSUSeconds

Since: 1.4.0.0

Methods

rnf :: CSUSeconds -> () #

NFData CFile

Since: 1.4.0.0

Methods

rnf :: CFile -> () #

NFData CFpos

Since: 1.4.0.0

Methods

rnf :: CFpos -> () #

NFData CJmpBuf

Since: 1.4.0.0

Methods

rnf :: CJmpBuf -> () #

NFData CIntPtr

Since: 1.4.0.0

Methods

rnf :: CIntPtr -> () #

NFData CUIntPtr

Since: 1.4.0.0

Methods

rnf :: CUIntPtr -> () #

NFData CIntMax

Since: 1.4.0.0

Methods

rnf :: CIntMax -> () #

NFData CUIntMax

Since: 1.4.0.0

Methods

rnf :: CUIntMax -> () #

NFData All

Since: 1.4.0.0

Methods

rnf :: All -> () #

NFData Any

Since: 1.4.0.0

Methods

rnf :: Any -> () #

NFData Fingerprint

Since: 1.4.0.0

Methods

rnf :: Fingerprint -> () #

NFData SrcLoc

Since: 1.4.2.0

Methods

rnf :: SrcLoc -> () #

NFData ByteString 

Methods

rnf :: ByteString -> () #

NFData ByteString 

Methods

rnf :: ByteString -> () #

NFData IntSet 

Methods

rnf :: IntSet -> () #

NFData Doc 

Methods

rnf :: Doc -> () #

NFData TextDetails 

Methods

rnf :: TextDetails -> () #

NFData LocalTime 

Methods

rnf :: LocalTime -> () #

NFData ZonedTime 

Methods

rnf :: ZonedTime -> () #

NFData TimeOfDay 

Methods

rnf :: TimeOfDay -> () #

NFData TimeZone 

Methods

rnf :: TimeZone -> () #

NFData UTCTime 

Methods

rnf :: UTCTime -> () #

NFData NominalDiffTime 

Methods

rnf :: NominalDiffTime -> () #

NFData Day 

Methods

rnf :: Day -> () #

NFData UniversalTime 

Methods

rnf :: UniversalTime -> () #

NFData DiffTime 

Methods

rnf :: DiffTime -> () #

NFData a => NFData [a] 

Methods

rnf :: [a] -> () #

NFData a => NFData (Maybe a) 

Methods

rnf :: Maybe a -> () #

NFData a => NFData (Ratio a) 

Methods

rnf :: Ratio a -> () #

NFData (Ptr a)

Since: 1.4.2.0

Methods

rnf :: Ptr a -> () #

NFData (FunPtr a)

Since: 1.4.2.0

Methods

rnf :: FunPtr a -> () #

NFData a => NFData (IntMap a) 

Methods

rnf :: IntMap a -> () #

NFData a => NFData (Identity a)

Since: 1.4.0.0

Methods

rnf :: Identity a -> () #

NFData a => NFData (Min a)

Since: 1.4.2.0

Methods

rnf :: Min a -> () #

NFData a => NFData (Max a)

Since: 1.4.2.0

Methods

rnf :: Max a -> () #

NFData a => NFData (First a)

Since: 1.4.2.0

Methods

rnf :: First a -> () #

NFData a => NFData (Last a)

Since: 1.4.2.0

Methods

rnf :: Last a -> () #

NFData m => NFData (WrappedMonoid m)

Since: 1.4.2.0

Methods

rnf :: WrappedMonoid m -> () #

NFData a => NFData (Option a)

Since: 1.4.2.0

Methods

rnf :: Option a -> () #

NFData a => NFData (NonEmpty a)

Since: 1.4.2.0

Methods

rnf :: NonEmpty a -> () #

NFData (Fixed a)

Since: 1.3.0.0

Methods

rnf :: Fixed a -> () #

NFData a => NFData (Complex a) 

Methods

rnf :: Complex a -> () #

NFData (StableName a)

Since: 1.4.0.0

Methods

rnf :: StableName a -> () #

NFData a => NFData (ZipList a)

Since: 1.4.0.0

Methods

rnf :: ZipList a -> () #

NFData a => NFData (Dual a)

Since: 1.4.0.0

Methods

rnf :: Dual a -> () #

NFData a => NFData (Sum a)

Since: 1.4.0.0

Methods

rnf :: Sum a -> () #

NFData a => NFData (Product a)

Since: 1.4.0.0

Methods

rnf :: Product a -> () #

NFData a => NFData (First a)

Since: 1.4.0.0

Methods

rnf :: First a -> () #

NFData a => NFData (Last a)

Since: 1.4.0.0

Methods

rnf :: Last a -> () #

NFData (IORef a)

NOTE: Only strict in the reference and not the referenced value.

Since: 1.4.2.0

Methods

rnf :: IORef a -> () #

NFData a => NFData (Down a)

Since: 1.4.0.0

Methods

rnf :: Down a -> () #

NFData (MVar a)

NOTE: Only strict in the reference and not the referenced value.

Since: 1.4.2.0

Methods

rnf :: MVar a -> () #

NFData a => NFData (Digit a) 

Methods

rnf :: Digit a -> () #

NFData a => NFData (Node a) 

Methods

rnf :: Node a -> () #

NFData a => NFData (Elem a) 

Methods

rnf :: Elem a -> () #

NFData a => NFData (FingerTree a) 

Methods

rnf :: FingerTree a -> () #

NFData a => NFData (Tree a) 

Methods

rnf :: Tree a -> () #

NFData a => NFData (Seq a) 

Methods

rnf :: Seq a -> () #

NFData a => NFData (Set a) 

Methods

rnf :: Set a -> () #

NFData a => NFData (Vector a) 

Methods

rnf :: Vector a -> () #

NFData (Vector a) 

Methods

rnf :: Vector a -> () #

NFData (Vector a) 

Methods

rnf :: Vector a -> () #

NFData (Vector a) 

Methods

rnf :: Vector a -> () #

NFData a => NFData (HashSet a) 

Methods

rnf :: HashSet a -> () #

NFData (IVar a) 

Methods

rnf :: IVar a -> () #

NFData a => NFData (Doc a) 

Methods

rnf :: Doc a -> () #

NFData a => NFData (AnnotDetails a) 

Methods

rnf :: AnnotDetails a -> () #

NFData a => NFData (Probability a) # 

Methods

rnf :: Probability a -> () #

NFData (a -> b)

This instance is for convenience and consistency with seq. This assumes that WHNF is equivalent to NF for functions.

Since: 1.3.0.0

Methods

rnf :: (a -> b) -> () #

(NFData a, NFData b) => NFData (Either a b) 

Methods

rnf :: Either a b -> () #

(NFData a, NFData b) => NFData (a, b) 

Methods

rnf :: (a, b) -> () #

(NFData a, NFData b) => NFData (Array a b) 

Methods

rnf :: Array a b -> () #

(NFData a, NFData b) => NFData (Arg a b)

Since: 1.4.2.0

Methods

rnf :: Arg a b -> () #

NFData (Proxy k a)

Since: 1.4.0.0

Methods

rnf :: Proxy k a -> () #

NFData (STRef s a)

NOTE: Only strict in the reference and not the referenced value.

Since: 1.4.2.0

Methods

rnf :: STRef s a -> () #

(NFData k, NFData a) => NFData (Map k a) 

Methods

rnf :: Map k a -> () #

(NFData k, NFData v) => NFData (HashMap k v) 

Methods

rnf :: HashMap k v -> () #

(NFData k, NFData v) => NFData (Leaf k v) 

Methods

rnf :: Leaf k v -> () #

NFData (MVector s a) 

Methods

rnf :: MVector s a -> () #

NFData (MVector s a) 

Methods

rnf :: MVector s a -> () #

NFData (MVector s a) 

Methods

rnf :: MVector s a -> () #

NFData a => NFData (Vector n a) # 

Methods

rnf :: Vector n a -> () #

NFData (Component f g) # 

Methods

rnf :: Component f g -> () #

(NFData a, NFData b, NFData c) => NFData (a, b, c) 

Methods

rnf :: (a, b, c) -> () #

NFData a => NFData (Const k a b)

Since: 1.4.0.0

Methods

rnf :: Const k a b -> () #

NFData b => NFData (Tagged k s b) 

Methods

rnf :: Tagged k s b -> () #

NFData a => NFData (Matrix m n a) # 

Methods

rnf :: Matrix m n a -> () #

(NFData (s a), NFData (t a)) => NFData (Pair s t a) # 

Methods

rnf :: Pair s t a -> () #

(NFData a, NFData b, NFData c, NFData d) => NFData (a, b, c, d) 

Methods

rnf :: (a, b, c, d) -> () #

(NFData a1, NFData a2, NFData a3, NFData a4, NFData a5) => NFData (a1, a2, a3, a4, a5) 

Methods

rnf :: (a1, a2, a3, a4, a5) -> () #

NFData (Model f g a b c) # 

Methods

rnf :: Model f g a b c -> () #

(NFData a1, NFData a2, NFData a3, NFData a4, NFData a5, NFData a6) => NFData (a1, a2, a3, a4, a5, a6) 

Methods

rnf :: (a1, a2, a3, a4, a5, a6) -> () #

(NFData a1, NFData a2, NFData a3, NFData a4, NFData a5, NFData a6, NFData a7) => NFData (a1, a2, a3, a4, a5, a6, a7) 

Methods

rnf :: (a1, a2, a3, a4, a5, a6, a7) -> () #

(NFData a1, NFData a2, NFData a3, NFData a4, NFData a5, NFData a6, NFData a7, NFData a8) => NFData (a1, a2, a3, a4, a5, a6, a7, a8) 

Methods

rnf :: (a1, a2, a3, a4, a5, a6, a7, a8) -> () #

(NFData a1, NFData a2, NFData a3, NFData a4, NFData a5, NFData a6, NFData a7, NFData a8, NFData a9) => NFData (a1, a2, a3, a4, a5, a6, a7, a8, a9) 

Methods

rnf :: (a1, a2, a3, a4, a5, a6, a7, a8, a9) -> () #

deepseq :: NFData a => a -> b -> b #

deepseq: fully evaluates the first argument, before returning the second.

The name deepseq is used to illustrate the relationship to seq: where seq is shallow in the sense that it only evaluates the top level of its argument, deepseq traverses the entire data structure evaluating it completely.

deepseq can be useful for forcing pending exceptions, eradicating space leaks, or forcing lazy I/O to happen. It is also useful in conjunction with parallel Strategies (see the parallel package).

There is no guarantee about the ordering of evaluation. The implementation may evaluate the components of the structure in any order or in parallel. To impose an actual order on evaluation, use pseq from Control.Parallel in the parallel package.

Since: 1.1.0.0

force :: NFData a => a -> a #

a variant of deepseq that is useful in some circumstances:

force x = x `deepseq` x

force x fully evaluates x, and then returns it. Note that force x only performs evaluation when the value of force x itself is demanded, so essentially it turns shallow evaluation into deep evaluation.

force can be conveniently used in combination with ViewPatterns:

{-# LANGUAGE BangPatterns, ViewPatterns #-}
import Control.DeepSeq

someFun :: ComplexData -> SomeResult
someFun (force -> !arg) = {- 'arg' will be fully evaluated -}

Another useful application is to combine force with evaluate in order to force deep evaluation relative to other IO operations:

import Control.Exception (evaluate)
import Control.DeepSeq

main = do
  result <- evaluate $ force $ pureComputation
  {- 'result' will be fully evaluated at this point -}
  return ()

Since: 1.2.0.0

(&) :: a -> (a -> b) -> b infixl 1 #

& is a reverse application operator. This provides notational convenience. Its precedence is one higher than that of the forward application operator $, which allows & to be nested in $.

Since: 4.8.0.0

(^.) :: s -> Getting a s a -> a infixl 8 #

View the value pointed to by a Getter or Lens or the result of folding over all the results of a Fold or Traversal that points at a monoidal values.

This is the same operation as view with the arguments flipped.

The fixity and semantics are such that subsequent field accesses can be performed with (.).

>>> (a,b)^._2
b
>>> ("hello","world")^._2
"world"
>>> import Data.Complex
>>> ((0, 1 :+ 2), 3)^._1._2.to magnitude
2.23606797749979
(^.) ::             s -> Getter s a     -> a
(^.) :: Monoid m => s -> Fold s m       -> m
(^.) ::             s -> Iso' s a       -> a
(^.) ::             s -> Lens' s a      -> a
(^.) :: Monoid m => s -> Traversal' s m -> m

(.~) :: ASetter s t a b -> b -> s -> t infixr 4 #

Replace the target of a Lens or all of the targets of a Setter or Traversal with a constant value.

This is an infix version of set, provided for consistency with (.=).

f <$ a ≡ mapped .~ f $ a
>>> (a,b,c,d) & _4 .~ e
(a,b,c,e)
>>> (42,"world") & _1 .~ "hello"
("hello","world")
>>> (a,b) & both .~ c
(c,c)
(.~) :: Setter s t a b    -> b -> s -> t
(.~) :: Iso s t a b       -> b -> s -> t
(.~) :: Lens s t a b      -> b -> s -> t
(.~) :: Traversal s t a b -> b -> s -> t

type Lens' s a = Lens s s a a #

type Lens' = Simple Lens

type Getter s a = forall f. (Contravariant f, Functor f) => (a -> f a) -> s -> f s #

A Getter describes how to retrieve a single value in a way that can be composed with other LensLike constructions.

Unlike a Lens a Getter is read-only. Since a Getter cannot be used to write back there are no Lens laws that can be applied to it. In fact, it is isomorphic to an arbitrary function from (s -> a).

Moreover, a Getter can be used directly as a Fold, since it just ignores the Applicative.

to :: (Profunctor p, Contravariant f) => (s -> a) -> Optic' * * p f s a #

Build an (index-preserving) Getter from an arbitrary Haskell function.

to f . to g ≡ to (g . f)
a ^. to f ≡ f a
>>> a ^.to f
f a
>>> ("hello","world")^.to snd
"world"
>>> 5^.to succ
6
>>> (0, -5)^._2.to abs
5
to :: (s -> a) -> IndexPreservingGetter s a

lens :: (s -> a) -> (s -> b -> t) -> Lens s t a b #

Build a Lens from a getter and a setter.

lens :: Functor f => (s -> a) -> (s -> b -> t) -> (a -> f b) -> s -> f t
>>> s ^. lens getter setter
getter s
>>> s & lens getter setter .~ b
setter s b
>>> s & lens getter setter %~ f
setter s (f (getter s))
lens :: (s -> a) -> (s -> a -> s) -> Lens' s a

when :: Applicative f => Bool -> f () -> f () #

Conditional execution of Applicative expressions. For example,

when debug (putStrLn "Debugging")

will output the string Debugging if the Boolean value debug is True, and otherwise do nothing.

unless :: Applicative f => Bool -> f () -> f () #

The reverse of when.

forM :: (Traversable t, Monad m) => t a -> (a -> m b) -> m (t b) #

forM is mapM with its arguments flipped. For a version that ignores the results see forM_.

forM_ :: (Foldable t, Monad m) => t a -> (a -> m b) -> m () #

forM_ is mapM_ with its arguments flipped. For a version that doesn't ignore the results see forM.

As of base 4.8.0.0, forM_ is just for_, specialized to Monad.

void :: Functor f => f a -> f () #

void value discards or ignores the result of evaluation, such as the return value of an IO action.

Examples

Replace the contents of a Maybe Int with unit:

>>> void Nothing
Nothing
>>> void (Just 3)
Just ()

Replace the contents of an Either Int Int with unit, resulting in an Either Int '()':

>>> void (Left 8675309)
Left 8675309
>>> void (Right 8675309)
Right ()

Replace every element of a list with unit:

>>> void [1,2,3]
[(),(),()]

Replace the second element of a pair with unit:

>>> void (1,2)
(1,())

Discard the result of an IO action:

>>> mapM print [1,2]
1
2
[(),()]
>>> void $ mapM print [1,2]
1
2

replicateM :: Applicative m => Int -> m a -> m [a] #

replicateM n act performs the action n times, gathering the results.

forever :: Applicative f => f a -> f b #

forever act repeats the action infinitely.

guard :: Alternative f => Bool -> f () #

guard b is pure () if b is True, and empty if b is False.

newtype Identity a :: * -> * #

Identity functor and monad. (a non-strict monad)

Since: 4.8.0.0

Constructors

Identity 

Fields

Instances

Monad Identity 

Methods

(>>=) :: Identity a -> (a -> Identity b) -> Identity b #

(>>) :: Identity a -> Identity b -> Identity b #

return :: a -> Identity a #

fail :: String -> Identity a #

Functor Identity 

Methods

fmap :: (a -> b) -> Identity a -> Identity b #

(<$) :: a -> Identity b -> Identity a #

MonadFix Identity 

Methods

mfix :: (a -> Identity a) -> Identity a #

Applicative Identity 

Methods

pure :: a -> Identity a #

(<*>) :: Identity (a -> b) -> Identity a -> Identity b #

(*>) :: Identity a -> Identity b -> Identity b #

(<*) :: Identity a -> Identity b -> Identity a #

Foldable Identity 

Methods

fold :: Monoid m => Identity m -> m #

foldMap :: Monoid m => (a -> m) -> Identity a -> m #

foldr :: (a -> b -> b) -> b -> Identity a -> b #

foldr' :: (a -> b -> b) -> b -> Identity a -> b #

foldl :: (b -> a -> b) -> b -> Identity a -> b #

foldl' :: (b -> a -> b) -> b -> Identity a -> b #

foldr1 :: (a -> a -> a) -> Identity a -> a #

foldl1 :: (a -> a -> a) -> Identity a -> a #

toList :: Identity a -> [a] #

null :: Identity a -> Bool #

length :: Identity a -> Int #

elem :: Eq a => a -> Identity a -> Bool #

maximum :: Ord a => Identity a -> a #

minimum :: Ord a => Identity a -> a #

sum :: Num a => Identity a -> a #

product :: Num a => Identity a -> a #

Traversable Identity 

Methods

traverse :: Applicative f => (a -> f b) -> Identity a -> f (Identity b) #

sequenceA :: Applicative f => Identity (f a) -> f (Identity a) #

mapM :: Monad m => (a -> m b) -> Identity a -> m (Identity b) #

sequence :: Monad m => Identity (m a) -> m (Identity a) #

Generic1 Identity 

Associated Types

type Rep1 (Identity :: * -> *) :: * -> * #

Methods

from1 :: Identity a -> Rep1 Identity a #

to1 :: Rep1 Identity a -> Identity a #

Representable Identity 

Associated Types

type Rep (Identity :: * -> *) :: * #

Methods

tabulate :: (Rep Identity -> a) -> Identity a #

index :: Identity a -> Rep Identity -> a #

Eq1 Identity 

Methods

liftEq :: (a -> b -> Bool) -> Identity a -> Identity b -> Bool #

Ord1 Identity 

Methods

liftCompare :: (a -> b -> Ordering) -> Identity a -> Identity b -> Ordering #

Read1 Identity 

Methods

liftReadsPrec :: (Int -> ReadS a) -> ReadS [a] -> Int -> ReadS (Identity a) #

liftReadList :: (Int -> ReadS a) -> ReadS [a] -> ReadS [Identity a] #

Show1 Identity 

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> Identity a -> ShowS #

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [Identity a] -> ShowS #

MonadZip Identity 

Methods

mzip :: Identity a -> Identity b -> Identity (a, b) #

mzipWith :: (a -> b -> c) -> Identity a -> Identity b -> Identity c #

munzip :: Identity (a, b) -> (Identity a, Identity b) #

Comonad Identity 

Methods

extract :: Identity a -> a #

duplicate :: Identity a -> Identity (Identity a) #

extend :: (Identity a -> b) -> Identity a -> Identity b #

ComonadApply Identity 

Methods

(<@>) :: Identity (a -> b) -> Identity a -> Identity b #

(@>) :: Identity a -> Identity b -> Identity b #

(<@) :: Identity a -> Identity b -> Identity a #

MonadBaseControl Identity Identity 

Associated Types

type StM (Identity :: * -> *) a :: * #

Sieve ReifiedGetter Identity 

Methods

sieve :: ReifiedGetter a b -> a -> Identity b #

Cosieve ReifiedGetter Identity 

Methods

cosieve :: ReifiedGetter a b -> Identity a -> b #

Bounded a => Bounded (Identity a) 
Enum a => Enum (Identity a) 
Eq a => Eq (Identity a) 

Methods

(==) :: Identity a -> Identity a -> Bool #

(/=) :: Identity a -> Identity a -> Bool #

Floating a => Floating (Identity a) 
Fractional a => Fractional (Identity a) 
Integral a => Integral (Identity a) 
Data a => Data (Identity a) 

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Identity a -> c (Identity a) #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Identity a) #

toConstr :: Identity a -> Constr #

dataTypeOf :: Identity a -> DataType #

dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c (Identity a)) #

dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Identity a)) #

gmapT :: (forall b. Data b => b -> b) -> Identity a -> Identity a #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Identity a -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Identity a -> r #

gmapQ :: (forall d. Data d => d -> u) -> Identity a -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Identity a -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Identity a -> m (Identity a) #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Identity a -> m (Identity a) #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Identity a -> m (Identity a) #

Num a => Num (Identity a) 
Ord a => Ord (Identity a) 

Methods

compare :: Identity a -> Identity a -> Ordering #

(<) :: Identity a -> Identity a -> Bool #

(<=) :: Identity a -> Identity a -> Bool #

(>) :: Identity a -> Identity a -> Bool #

(>=) :: Identity a -> Identity a -> Bool #

max :: Identity a -> Identity a -> Identity a #

min :: Identity a -> Identity a -> Identity a #

Read a => Read (Identity a)

This instance would be equivalent to the derived instances of the Identity newtype if the runIdentity field were removed

Real a => Real (Identity a) 

Methods

toRational :: Identity a -> Rational #

RealFloat a => RealFloat (Identity a) 
RealFrac a => RealFrac (Identity a) 

Methods

properFraction :: Integral b => Identity a -> (b, Identity a) #

truncate :: Integral b => Identity a -> b #

round :: Integral b => Identity a -> b #

ceiling :: Integral b => Identity a -> b #

floor :: Integral b => Identity a -> b #

Show a => Show (Identity a)

This instance would be equivalent to the derived instances of the Identity newtype if the runIdentity field were removed

Methods

showsPrec :: Int -> Identity a -> ShowS #

show :: Identity a -> String #

showList :: [Identity a] -> ShowS #

Ix a => Ix (Identity a) 
IsString a => IsString (Identity a) 

Methods

fromString :: String -> Identity a #

Generic (Identity a) 

Associated Types

type Rep (Identity a) :: * -> * #

Methods

from :: Identity a -> Rep (Identity a) x #

to :: Rep (Identity a) x -> Identity a #

Semigroup a => Semigroup (Identity a) 

Methods

(<>) :: Identity a -> Identity a -> Identity a #

sconcat :: NonEmpty (Identity a) -> Identity a #

stimes :: Integral b => b -> Identity a -> Identity a #

Monoid a => Monoid (Identity a) 

Methods

mempty :: Identity a #

mappend :: Identity a -> Identity a -> Identity a #

mconcat :: [Identity a] -> Identity a #

NFData a => NFData (Identity a)

Since: 1.4.0.0

Methods

rnf :: Identity a -> () #

Storable a => Storable (Identity a) 

Methods

sizeOf :: Identity a -> Int #

alignment :: Identity a -> Int #

peekElemOff :: Ptr (Identity a) -> Int -> IO (Identity a) #

pokeElemOff :: Ptr (Identity a) -> Int -> Identity a -> IO () #

peekByteOff :: Ptr b -> Int -> IO (Identity a) #

pokeByteOff :: Ptr b -> Int -> Identity a -> IO () #

peek :: Ptr (Identity a) -> IO (Identity a) #

poke :: Ptr (Identity a) -> Identity a -> IO () #

Bits a => Bits (Identity a) 
FiniteBits a => FiniteBits (Identity a) 
Ixed (Identity a) 

Methods

ix :: Index (Identity a) -> Traversal' (Identity a) (IxValue (Identity a)) #

Wrapped (Identity a) 

Associated Types

type Unwrapped (Identity a) :: * #

(~) * t (Identity b) => Rewrapped (Identity a) t 
Field1 (Identity a) (Identity b) a b 

Methods

_1 :: Lens (Identity a) (Identity b) a b #

type Rep1 Identity 
type Rep1 Identity = D1 (MetaData "Identity" "Data.Functor.Identity" "base" True) (C1 (MetaCons "Identity" PrefixI True) (S1 (MetaSel (Just Symbol "runIdentity") NoSourceUnpackedness NoSourceStrictness DecidedLazy) Par1))
type Rep Identity 
type Rep Identity = ()
type StM Identity a 
type StM Identity a = a
type Rep (Identity a) 
type Rep (Identity a) = D1 (MetaData "Identity" "Data.Functor.Identity" "base" True) (C1 (MetaCons "Identity" PrefixI True) (S1 (MetaSel (Just Symbol "runIdentity") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 a)))
type Index (Identity a) 
type Index (Identity a) = ()
type IxValue (Identity a) 
type IxValue (Identity a) = a
type Unwrapped (Identity a) 
type Unwrapped (Identity a) = a

class Monad m => MonadIO m where #

Monads in which IO computations may be embedded. Any monad built by applying a sequence of monad transformers to the IO monad will be an instance of this class.

Instances should satisfy the following laws, which state that liftIO is a transformer of monads:

Instances

MonadIO IO 

Methods

liftIO :: IO a -> IO a #

MonadIO m => MonadIO (CatchT m) 

Methods

liftIO :: IO a -> CatchT m a #

MonadIO m => MonadIO (MaybeT m) 

Methods

liftIO :: IO a -> MaybeT m a #

MonadIO m => MonadIO (Codensity m) 

Methods

liftIO :: IO a -> Codensity m a #

MonadIO m => MonadIO (ListT m) 

Methods

liftIO :: IO a -> ListT m a #

MonadIO m => MonadIO (ListT m) 

Methods

liftIO :: IO a -> ListT m a #

MonadIO m => MonadIO (SafeT m) 

Methods

liftIO :: IO a -> SafeT m a #

MonadIO m => MonadIO (RandT g m) 

Methods

liftIO :: IO a -> RandT g m a #

MonadIO m => MonadIO (IdentityT * m) 

Methods

liftIO :: IO a -> IdentityT * m a #

(Functor f, MonadIO m) => MonadIO (FreeT f m) 

Methods

liftIO :: IO a -> FreeT f m a #

(Error e, MonadIO m) => MonadIO (ErrorT e m) 

Methods

liftIO :: IO a -> ErrorT e m a #

MonadIO m => MonadIO (ExceptT e m) 

Methods

liftIO :: IO a -> ExceptT e m a #

MonadIO m => MonadIO (StateT s m) 

Methods

liftIO :: IO a -> StateT s m a #

MonadIO m => MonadIO (StateT s m) 

Methods

liftIO :: IO a -> StateT s m a #

(Monoid w, MonadIO m) => MonadIO (WriterT w m) 

Methods

liftIO :: IO a -> WriterT w m a #

(Monoid w, MonadIO m) => MonadIO (WriterT w m) 

Methods

liftIO :: IO a -> WriterT w m a #

MonadIO m => MonadIO (ContT * r m) 

Methods

liftIO :: IO a -> ContT * r m a #

MonadIO m => MonadIO (ReaderT * r m) 

Methods

liftIO :: IO a -> ReaderT * r m a #

(Monoid w, MonadIO m) => MonadIO (RWST r w s m) 

Methods

liftIO :: IO a -> RWST r w s m a #

(Monoid w, MonadIO m) => MonadIO (RWST r w s m) 

Methods

liftIO :: IO a -> RWST r w s m a #

MonadIO m => MonadIO (Proxy a' a b' b m) 

Methods

liftIO :: IO a -> Proxy a' a b' b m a #

class Monad m => MonadRandom m where #

An interface to random number generation monads.

Minimal complete definition

getRandom, getRandoms, getRandomR, getRandomRs

Instances

(Monad m, RandomGen g) => MonadRandom (RandT g m) 

Methods

getRandom :: Random a => RandT g m a #

getRandoms :: Random a => RandT g m [a] #

getRandomR :: Random a => (a, a) -> RandT g m a #

getRandomRs :: Random a => (a, a) -> RandT g m [a] #

getRandom :: MonadRandom m => forall a. Random a => m a #

Return a randomly-selected value of type a. See random for details.

getRandomR :: MonadRandom m => forall a. Random a => (a, a) -> m a #

Return a randomly-selected value of type a in the range [lo,hi]. See randomR for details.

type Rand g = RandT g Identity #

A basic random monad.

data RandT g m a :: * -> (* -> *) -> * -> * #

A monad transformer which adds a random number generator to an existing monad.

Instances

(Monad m, RandomGen g) => MonadSplit g (RandT g m) 

Methods

getSplit :: RandT g m g #

MonadState s m => MonadState s (RandT g m) 

Methods

get :: RandT g m s #

put :: s -> RandT g m () #

state :: (s -> (a, s)) -> RandT g m a #

MonadReader r m => MonadReader r (RandT g m) 

Methods

ask :: RandT g m r #

local :: (r -> r) -> RandT g m a -> RandT g m a #

reader :: (r -> a) -> RandT g m a #

MonadWriter w m => MonadWriter w (RandT g m) 

Methods

writer :: (a, w) -> RandT g m a #

tell :: w -> RandT g m () #

listen :: RandT g m a -> RandT g m (a, w) #

pass :: RandT g m (a, w -> w) -> RandT g m a #

MonadTrans (RandT g) 

Methods

lift :: Monad m => m a -> RandT g m a #

Monad m => Monad (RandT g m) 

Methods

(>>=) :: RandT g m a -> (a -> RandT g m b) -> RandT g m b #

(>>) :: RandT g m a -> RandT g m b -> RandT g m b #

return :: a -> RandT g m a #

fail :: String -> RandT g m a #

Functor m => Functor (RandT g m) 

Methods

fmap :: (a -> b) -> RandT g m a -> RandT g m b #

(<$) :: a -> RandT g m b -> RandT g m a #

MonadFix m => MonadFix (RandT g m) 

Methods

mfix :: (a -> RandT g m a) -> RandT g m a #

(Functor m, Monad m) => Applicative (RandT g m) 

Methods

pure :: a -> RandT g m a #

(<*>) :: RandT g m (a -> b) -> RandT g m a -> RandT g m b #

(*>) :: RandT g m a -> RandT g m b -> RandT g m b #

(<*) :: RandT g m a -> RandT g m b -> RandT g m a #

(Monad m, RandomGen g) => MonadRandom (RandT g m) 

Methods

getRandom :: Random a => RandT g m a #

getRandoms :: Random a => RandT g m [a] #

getRandomR :: Random a => (a, a) -> RandT g m a #

getRandomRs :: Random a => (a, a) -> RandT g m [a] #

MonadIO m => MonadIO (RandT g m) 

Methods

liftIO :: IO a -> RandT g m a #

(Functor m, MonadPlus m) => Alternative (RandT g m) 

Methods

empty :: RandT g m a #

(<|>) :: RandT g m a -> RandT g m a -> RandT g m a #

some :: RandT g m a -> RandT g m [a] #

many :: RandT g m a -> RandT g m [a] #

MonadPlus m => MonadPlus (RandT g m) 

Methods

mzero :: RandT g m a #

mplus :: RandT g m a -> RandT g m a -> RandT g m a #

runRand :: Rand g a -> g -> (a, g) #

Run a random computation using the generator g, returning the result and the updated generator.

evalRand :: Rand g a -> g -> a #

Evaluate a random computation using the generator g. Note that the generator g is not returned, so there's no way to recover the updated version of g.

runRandT :: RandT g m a -> g -> m (a, g) #

Run a RandT computation using the generator g, returning the result and the updated generator.

evalRandT :: Monad m => RandT g m a -> g -> m a #

Evaluate a RandT computation using the generator g. Note that the generator g is not returned, so there's no way to recover the updated version of g.

data StdGen :: * #

The StdGen instance of RandomGen has a genRange of at least 30 bits.

The result of repeatedly using next should be at least as statistically robust as the Minimal Standard Random Number Generator described by [System.Random, System.Random]. Until more is known about implementations of split, all we require is that split deliver generators that are (a) not identical and (b) independently robust in the sense just given.

The Show and Read instances of StdGen provide a primitive way to save the state of a random number generator. It is required that read (show g) == g.

In addition, reads may be used to map an arbitrary string (not necessarily one produced by show) onto a value of type StdGen. In general, the Read instance of StdGen has the following properties:

  • It guarantees to succeed on any string.
  • It guarantees to consume only a finite portion of the string.
  • Different argument strings are likely to result in different results.

mkStdGen :: Int -> StdGen #

The function mkStdGen provides an alternative way of producing an initial generator, by mapping an Int into a generator. Again, distinct arguments should be likely to produce distinct generators.

class Monad m => MonadState s m | m -> s where #

Minimal definition is either both of get and put or just state

Minimal complete definition

state | get, put

Instances

MonadState s m => MonadState s (CatchT m) 

Methods

get :: CatchT m s #

put :: s -> CatchT m () #

state :: (s -> (a, s)) -> CatchT m a #

MonadState s m => MonadState s (SafeT m) 

Methods

get :: SafeT m s #

put :: s -> SafeT m () #

state :: (s -> (a, s)) -> SafeT m a #

MonadState s m => MonadState s (ListT m) 

Methods

get :: ListT m s #

put :: s -> ListT m () #

state :: (s -> (a, s)) -> ListT m a #

MonadReader r m => MonadState r (Codensity m) 

Methods

get :: Codensity m r #

put :: r -> Codensity m () #

state :: (r -> (a, r)) -> Codensity m a #

MonadState s m => MonadState s (MaybeT m) 

Methods

get :: MaybeT m s #

put :: s -> MaybeT m () #

state :: (s -> (a, s)) -> MaybeT m a #

MonadState s m => MonadState s (ListT m) 

Methods

get :: ListT m s #

put :: s -> ListT m () #

state :: (s -> (a, s)) -> ListT m a #

(Functor f, MonadState s m) => MonadState s (FreeT f m) 

Methods

get :: FreeT f m s #

put :: s -> FreeT f m () #

state :: (s -> (a, s)) -> FreeT f m a #

(Monoid w, MonadState s m) => MonadState s (WriterT w m) 

Methods

get :: WriterT w m s #

put :: s -> WriterT w m () #

state :: (s -> (a, s)) -> WriterT w m a #

(Monoid w, MonadState s m) => MonadState s (WriterT w m) 

Methods

get :: WriterT w m s #

put :: s -> WriterT w m () #

state :: (s -> (a, s)) -> WriterT w m a #

Monad m => MonadState s (StateT s m) 

Methods

get :: StateT s m s #

put :: s -> StateT s m () #

state :: (s -> (a, s)) -> StateT s m a #

Monad m => MonadState s (StateT s m) 

Methods

get :: StateT s m s #

put :: s -> StateT s m () #

state :: (s -> (a, s)) -> StateT s m a #

MonadState s m => MonadState s (IdentityT * m) 

Methods

get :: IdentityT * m s #

put :: s -> IdentityT * m () #

state :: (s -> (a, s)) -> IdentityT * m a #

MonadState s m => MonadState s (ExceptT e m) 

Methods

get :: ExceptT e m s #

put :: s -> ExceptT e m () #

state :: (s -> (a, s)) -> ExceptT e m a #

(Error e, MonadState s m) => MonadState s (ErrorT e m) 

Methods

get :: ErrorT e m s #

put :: s -> ErrorT e m () #

state :: (s -> (a, s)) -> ErrorT e m a #

MonadState s m => MonadState s (RandT g m) 

Methods

get :: RandT g m s #

put :: s -> RandT g m () #

state :: (s -> (a, s)) -> RandT g m a #

MonadState s m => MonadState s (ReaderT * r m) 

Methods

get :: ReaderT * r m s #

put :: s -> ReaderT * r m () #

state :: (s -> (a, s)) -> ReaderT * r m a #

MonadState s m => MonadState s (ContT * r m) 

Methods

get :: ContT * r m s #

put :: s -> ContT * r m () #

state :: (s -> (a, s)) -> ContT * r m a #

(Monad m, Monoid w) => MonadState s (RWST r w s m) 

Methods

get :: RWST r w s m s #

put :: s -> RWST r w s m () #

state :: (s -> (a, s)) -> RWST r w s m a #

(Monad m, Monoid w) => MonadState s (RWST r w s m) 

Methods

get :: RWST r w s m s #

put :: s -> RWST r w s m () #

state :: (s -> (a, s)) -> RWST r w s m a #

MonadState s m => MonadState s (Proxy a' a b' b m) 

Methods

get :: Proxy a' a b' b m s #

put :: s -> Proxy a' a b' b m () #

state :: (s -> (a, s)) -> Proxy a' a b' b m a #

lift :: MonadTrans t => forall m a. Monad m => m a -> t m a #

Lift a computation from the argument monad to the constructed monad.

type State s = StateT s Identity #

A state monad parameterized by the type s of the state to carry.

The return function leaves the state unchanged, while >>= uses the final state of the first computation as the initial state of the second.

data StateT s m a :: * -> (* -> *) -> * -> * #

A state transformer monad parameterized by:

  • s - The state.
  • m - The inner monad.

The return function leaves the state unchanged, while >>= uses the final state of the first computation as the initial state of the second.

Instances

Monad m => MonadState s (StateT s m) 

Methods

get :: StateT s m s #

put :: s -> StateT s m () #

state :: (s -> (a, s)) -> StateT s m a #

MonadReader r m => MonadReader r (StateT s m) 

Methods

ask :: StateT s m r #

local :: (r -> r) -> StateT s m a -> StateT s m a #

reader :: (r -> a) -> StateT s m a #

MonadBaseControl b m => MonadBaseControl b (StateT s m) 

Associated Types

type StM (StateT s m :: * -> *) a :: * #

Methods

liftBaseWith :: (RunInBase (StateT s m) b -> b a) -> StateT s m a #

restoreM :: StM (StateT s m) a -> StateT s m a #

MonadTrans (StateT s) 

Methods

lift :: Monad m => m a -> StateT s m a #

MonadTransControl (StateT s) 

Associated Types

type StT (StateT s :: (* -> *) -> * -> *) a :: * #

Methods

liftWith :: Monad m => (Run (StateT s) -> m a) -> StateT s m a #

restoreT :: Monad m => m (StT (StateT s) a) -> StateT s m a #

Monad m => Monad (StateT s m) 

Methods

(>>=) :: StateT s m a -> (a -> StateT s m b) -> StateT s m b #

(>>) :: StateT s m a -> StateT s m b -> StateT s m b #

return :: a -> StateT s m a #

fail :: String -> StateT s m a #

Functor m => Functor (StateT s m) 

Methods

fmap :: (a -> b) -> StateT s m a -> StateT s m b #

(<$) :: a -> StateT s m b -> StateT s m a #

MonadFix m => MonadFix (StateT s m) 

Methods

mfix :: (a -> StateT s m a) -> StateT s m a #

MonadFail m => MonadFail (StateT s m) 

Methods

fail :: String -> StateT s m a #

(Functor m, Monad m) => Applicative (StateT s m) 

Methods

pure :: a -> StateT s m a #

(<*>) :: StateT s m (a -> b) -> StateT s m a -> StateT s m b #

(*>) :: StateT s m a -> StateT s m b -> StateT s m b #

(<*) :: StateT s m a -> StateT s m b -> StateT s m a #

Contravariant m => Contravariant (StateT s m) 

Methods

contramap :: (a -> b) -> StateT s m b -> StateT s m a #

(>$) :: b -> StateT s m b -> StateT s m a #

MonadIO m => MonadIO (StateT s m) 

Methods

liftIO :: IO a -> StateT s m a #

(Functor m, MonadPlus m) => Alternative (StateT s m) 

Methods

empty :: StateT s m a #

(<|>) :: StateT s m a -> StateT s m a -> StateT s m a #

some :: StateT s m a -> StateT s m [a] #

many :: StateT s m a -> StateT s m [a] #

MonadPlus m => MonadPlus (StateT s m) 

Methods

mzero :: StateT s m a #

mplus :: StateT s m a -> StateT s m a -> StateT s m a #

MonadThrow m => MonadThrow (StateT s m) 

Methods

throwM :: Exception e => e -> StateT s m a #

MonadCatch m => MonadCatch (StateT s m) 

Methods

catch :: Exception e => StateT s m a -> (e -> StateT s m a) -> StateT s m a #

MonadMask m => MonadMask (StateT s m) 

Methods

mask :: ((forall a. StateT s m a -> StateT s m a) -> StateT s m b) -> StateT s m b #

uninterruptibleMask :: ((forall a. StateT s m a -> StateT s m a) -> StateT s m b) -> StateT s m b #

MonadSafe m => MonadSafe (StateT s m) 

Associated Types

type Base (StateT s m :: * -> *) :: * -> * #

Methods

liftBase :: Base (StateT s m) r -> StateT s m r #

register :: Base (StateT s m) () -> StateT s m ReleaseKey #

release :: ReleaseKey -> StateT s m () #

PrimMonad m => PrimMonad (StateT s m) 

Associated Types

type PrimState (StateT s m :: * -> *) :: * #

Methods

primitive :: (State# (PrimState (StateT s m)) -> (#VoidRep, PtrRepLifted, State# (PrimState (StateT s m)), a#)) -> StateT s m a #

Monad z => Zoom (StateT s z) (StateT t z) s t 

Methods

zoom :: LensLike' (Zoomed (StateT s z) c) t s -> StateT s z c -> StateT t z c #

Wrapped (StateT s m a) 

Associated Types

type Unwrapped (StateT s m a) :: * #

Methods

_Wrapped' :: Iso' (StateT s m a) (Unwrapped (StateT s m a)) #

(~) * t (StateT s' m' a') => Rewrapped (StateT s m a) t 
type StT (StateT s) a 
type StT (StateT s) a = (a, s)
type Zoomed (StateT s z) 
type Zoomed (StateT s z) = Focusing z
type Base (StateT s m) 
type Base (StateT s m) = Base m
type PrimState (StateT s m) 
type PrimState (StateT s m) = PrimState m
type StM (StateT s m) a 
type StM (StateT s m) a = ComposeSt (StateT s) m a
type Unwrapped (StateT s m a) 
type Unwrapped (StateT s m a) = s -> m (a, s)

modify :: Monad m => (s -> s) -> StateT s m () #

modify f is an action that updates the state to the result of applying f to the current state.

runState #

Arguments

:: State s a

state-passing computation to execute

-> s

initial state

-> (a, s)

return value and final state

Unwrap a state monad computation as a function. (The inverse of state.)

evalState #

Arguments

:: State s a

state-passing computation to execute

-> s

initial value

-> a

return value of the state computation

Evaluate a state computation with the given initial state and return the final value, discarding the final state.

execState #

Arguments

:: State s a

state-passing computation to execute

-> s

initial value

-> s

final state

Evaluate a state computation with the given initial state and return the final state, discarding the final value.

runStateT :: StateT s m a -> s -> m (a, s) #

evalStateT :: Monad m => StateT s m a -> s -> m a #

Evaluate a state computation with the given initial state and return the final value, discarding the final state.

execStateT :: Monad m => StateT s m a -> s -> m s #

Evaluate a state computation with the given initial state and return the final state, discarding the final value.

type Writer w = WriterT w Identity #

A writer monad parameterized by the type w of output to accumulate.

The return function produces the output mempty, while >>= combines the outputs of the subcomputations using mappend.

data WriterT w m a :: * -> (* -> *) -> * -> * #

A writer monad parameterized by:

  • w - the output to accumulate.
  • m - The inner monad.

The return function produces the output mempty, while >>= combines the outputs of the subcomputations using mappend.

Instances

(Monoid w, MonadState s m) => MonadState s (WriterT w m) 

Methods

get :: WriterT w m s #

put :: s -> WriterT w m () #

state :: (s -> (a, s)) -> WriterT w m a #

(Monoid w, MonadReader r m) => MonadReader r (WriterT w m) 

Methods

ask :: WriterT w m r #

local :: (r -> r) -> WriterT w m a -> WriterT w m a #

reader :: (r -> a) -> WriterT w m a #

(Monoid w, MonadBaseControl b m) => MonadBaseControl b (WriterT w m) 

Associated Types

type StM (WriterT w m :: * -> *) a :: * #

Methods

liftBaseWith :: (RunInBase (WriterT w m) b -> b a) -> WriterT w m a #

restoreM :: StM (WriterT w m) a -> WriterT w m a #

Monoid w => MonadTrans (WriterT w) 

Methods

lift :: Monad m => m a -> WriterT w m a #

Monoid w => MonadTransControl (WriterT w) 

Associated Types

type StT (WriterT w :: (* -> *) -> * -> *) a :: * #

Methods

liftWith :: Monad m => (Run (WriterT w) -> m a) -> WriterT w m a #

restoreT :: Monad m => m (StT (WriterT w) a) -> WriterT w m a #

(Monoid w, Monad m) => Monad (WriterT w m) 

Methods

(>>=) :: WriterT w m a -> (a -> WriterT w m b) -> WriterT w m b #

(>>) :: WriterT w m a -> WriterT w m b -> WriterT w m b #

return :: a -> WriterT w m a #

fail :: String -> WriterT w m a #

Functor m => Functor (WriterT w m) 

Methods

fmap :: (a -> b) -> WriterT w m a -> WriterT w m b #

(<$) :: a -> WriterT w m b -> WriterT w m a #

(Monoid w, MonadFix m) => MonadFix (WriterT w m) 

Methods

mfix :: (a -> WriterT w m a) -> WriterT w m a #

(Monoid w, MonadFail m) => MonadFail (WriterT w m) 

Methods

fail :: String -> WriterT w m a #

(Monoid w, Applicative m) => Applicative (WriterT w m) 

Methods

pure :: a -> WriterT w m a #

(<*>) :: WriterT w m (a -> b) -> WriterT w m a -> WriterT w m b #

(*>) :: WriterT w m a -> WriterT w m b -> WriterT w m b #

(<*) :: WriterT w m a -> WriterT w m b -> WriterT w m a #

Foldable f => Foldable (WriterT w f) 

Methods

fold :: Monoid m => WriterT w f m -> m #

foldMap :: Monoid m => (a -> m) -> WriterT w f a -> m #

foldr :: (a -> b -> b) -> b -> WriterT w f a -> b #

foldr' :: (a -> b -> b) -> b -> WriterT w f a -> b #

foldl :: (b -> a -> b) -> b -> WriterT w f a -> b #

foldl' :: (b -> a -> b) -> b -> WriterT w f a -> b #

foldr1 :: (a -> a -> a) -> WriterT w f a -> a #

foldl1 :: (a -> a -> a) -> WriterT w f a -> a #

toList :: WriterT w f a -> [a] #

null :: WriterT w f a -> Bool #

length :: WriterT w f a -> Int #

elem :: Eq a => a -> WriterT w f a -> Bool #

maximum :: Ord a => WriterT w f a -> a #

minimum :: Ord a => WriterT w f a -> a #

sum :: Num a => WriterT w f a -> a #

product :: Num a => WriterT w f a -> a #

Traversable f => Traversable (WriterT w f) 

Methods

traverse :: Applicative f => (a -> f b) -> WriterT w f a -> f (WriterT w f b) #

sequenceA :: Applicative f => WriterT w f (f a) -> f (WriterT w f a) #

mapM :: Monad m => (a -> m b) -> WriterT w f a -> m (WriterT w f b) #

sequence :: Monad m => WriterT w f (m a) -> m (WriterT w f a) #

Contravariant m => Contravariant (WriterT w m) 

Methods

contramap :: (a -> b) -> WriterT w m b -> WriterT w m a #

(>$) :: b -> WriterT w m b -> WriterT w m a #

(Eq w, Eq1 m) => Eq1 (WriterT w m) 

Methods

liftEq :: (a -> b -> Bool) -> WriterT w m a -> WriterT w m b -> Bool #

(Ord w, Ord1 m) => Ord1 (WriterT w m) 

Methods

liftCompare :: (a -> b -> Ordering) -> WriterT w m a -> WriterT w m b -> Ordering #

(Read w, Read1 m) => Read1 (WriterT w m) 

Methods

liftReadsPrec :: (Int -> ReadS a) -> ReadS [a] -> Int -> ReadS (WriterT w m a) #

liftReadList :: (Int -> ReadS a) -> ReadS [a] -> ReadS [WriterT w m a] #

(Show w, Show1 m) => Show1 (WriterT w m) 

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> WriterT w m a -> ShowS #

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [WriterT w m a] -> ShowS #

(Monoid w, MonadZip m) => MonadZip (WriterT w m) 

Methods

mzip :: WriterT w m a -> WriterT w m b -> WriterT w m (a, b) #

mzipWith :: (a -> b -> c) -> WriterT w m a -> WriterT w m b -> WriterT w m c #

munzip :: WriterT w m (a, b) -> (WriterT w m a, WriterT w m b) #

(Monoid w, MonadIO m) => MonadIO (WriterT w m) 

Methods

liftIO :: IO a -> WriterT w m a #

(Monoid w, Alternative m) => Alternative (WriterT w m) 

Methods

empty :: WriterT w m a #

(<|>) :: WriterT w m a -> WriterT w m a -> WriterT w m a #

some :: WriterT w m a -> WriterT w m [a] #

many :: WriterT w m a -> WriterT w m [a] #

(Monoid w, MonadPlus m) => MonadPlus (WriterT w m) 

Methods

mzero :: WriterT w m a #

mplus :: WriterT w m a -> WriterT w m a -> WriterT w m a #

(MonadThrow m, Monoid w) => MonadThrow (WriterT w m) 

Methods

throwM :: Exception e => e -> WriterT w m a #

(MonadCatch m, Monoid w) => MonadCatch (WriterT w m) 

Methods

catch :: Exception e => WriterT w m a -> (e -> WriterT w m a) -> WriterT w m a #

(MonadMask m, Monoid w) => MonadMask (WriterT w m) 

Methods

mask :: ((forall a. WriterT w m a -> WriterT w m a) -> WriterT w m b) -> WriterT w m b #

uninterruptibleMask :: ((forall a. WriterT w m a -> WriterT w m a) -> WriterT w m b) -> WriterT w m b #

(MonadSafe m, Monoid w) => MonadSafe (WriterT w m) 

Associated Types

type Base (WriterT w m :: * -> *) :: * -> * #

Methods

liftBase :: Base (WriterT w m) r -> WriterT w m r #

register :: Base (WriterT w m) () -> WriterT w m ReleaseKey #

release :: ReleaseKey -> WriterT w m () #

(Monoid w, PrimMonad m) => PrimMonad (WriterT w m) 

Associated Types

type PrimState (WriterT w m :: * -> *) :: * #

Methods

primitive :: (State# (PrimState (WriterT w m)) -> (#VoidRep, PtrRepLifted, State# (PrimState (WriterT w m)), a#)) -> WriterT w m a #

(Monoid w, Zoom m n s t) => Zoom (WriterT w m) (WriterT w n) s t 

Methods

zoom :: LensLike' (Zoomed (WriterT w m) c) t s -> WriterT w m c -> WriterT w n c #

(Eq w, Eq1 m, Eq a) => Eq (WriterT w m a) 

Methods

(==) :: WriterT w m a -> WriterT w m a -> Bool #

(/=) :: WriterT w m a -> WriterT w m a -> Bool #

(Ord w, Ord1 m, Ord a) => Ord (WriterT w m a) 

Methods

compare :: WriterT w m a -> WriterT w m a -> Ordering #

(<) :: WriterT w m a -> WriterT w m a -> Bool #

(<=) :: WriterT w m a -> WriterT w m a -> Bool #

(>) :: WriterT w m a -> WriterT w m a -> Bool #

(>=) :: WriterT w m a -> WriterT w m a -> Bool #

max :: WriterT w m a -> WriterT w m a -> WriterT w m a #

min :: WriterT w m a -> WriterT w m a -> WriterT w m a #

(Read w, Read1 m, Read a) => Read (WriterT w m a) 

Methods

readsPrec :: Int -> ReadS (WriterT w m a) #

readList :: ReadS [WriterT w m a] #

readPrec :: ReadPrec (WriterT w m a) #

readListPrec :: ReadPrec [WriterT w m a] #

(Show w, Show1 m, Show a) => Show (WriterT w m a) 

Methods

showsPrec :: Int -> WriterT w m a -> ShowS #

show :: WriterT w m a -> String #

showList :: [WriterT w m a] -> ShowS #

Wrapped (WriterT w m a) 

Associated Types

type Unwrapped (WriterT w m a) :: * #

Methods

_Wrapped' :: Iso' (WriterT w m a) (Unwrapped (WriterT w m a)) #

(~) * t (WriterT w' m' a') => Rewrapped (WriterT w m a) t 
type StT (WriterT w) a 
type StT (WriterT w) a = (a, w)
type Zoomed (WriterT w m) 
type Zoomed (WriterT w m) = FocusingPlus w (Zoomed m)
type Base (WriterT w m) 
type Base (WriterT w m) = Base m
type PrimState (WriterT w m) 
type PrimState (WriterT w m) = PrimState m
type StM (WriterT w m) a 
type StM (WriterT w m) a = ComposeSt (WriterT w) m a
type Unwrapped (WriterT w m a) 
type Unwrapped (WriterT w m a) = m (a, w)

tell :: Monad m => w -> WriterT w m () #

tell w is an action that produces the output w.

runWriter :: Writer w a -> (a, w) #

Unwrap a writer computation as a (result, output) pair. (The inverse of writer.)

execWriter :: Writer w a -> w #

Extract the output from a writer computation.

runWriterT :: WriterT w m a -> m (a, w) #

execWriterT :: Monad m => WriterT w m a -> m w #

Extract the output from a writer computation.

lefts :: [Either a b] -> [a] #

Extracts from a list of Either all the Left elements. All the Left elements are extracted in order.

Examples

Basic usage:

>>> let list = [ Left "foo", Right 3, Left "bar", Right 7, Left "baz" ]
>>> lefts list
["foo","bar","baz"]

rights :: [Either a b] -> [b] #

Extracts from a list of Either all the Right elements. All the Right elements are extracted in order.

Examples

Basic usage:

>>> let list = [ Left "foo", Right 3, Left "bar", Right 7, Left "baz" ]
>>> rights list
[3,7]

toList :: Foldable t => forall a. t a -> [a] #

List of elements of a structure, from left to right.

on :: (b -> b -> c) -> (a -> b) -> a -> a -> c infixl 0 #

(*) `on` f = \x y -> f x * f y.

Typical usage: sortBy (compare `on` fst).

Algebraic properties:

  • (*) `on` id = (*) (if (*) ∉ {⊥, const ⊥})
  • ((*) `on` f) `on` g = (*) `on` (f . g)
  • flip on f . flip on g = flip on (g . f)

sort :: Ord a => [a] -> [a] #

The sort function implements a stable sorting algorithm. It is a special case of sortBy, which allows the programmer to supply their own comparison function.

sortBy :: (a -> a -> Ordering) -> [a] -> [a] #

The sortBy function is the non-overloaded version of sort.

minimumBy :: Foldable t => (a -> a -> Ordering) -> t a -> a #

The least element of a non-empty structure with respect to the given comparison function.

maximumBy :: Foldable t => (a -> a -> Ordering) -> t a -> a #

The largest element of a non-empty structure with respect to the given comparison function.

foldl' :: Foldable t => forall b a. (b -> a -> b) -> b -> t a -> b #

Left-associative fold of a structure but with strict application of the operator.

This ensures that each step of the fold is forced to weak head normal form before being applied, avoiding the collection of thunks that would otherwise occur. This is often what you want to strictly reduce a finite list to a single, monolithic result (e.g. length).

For a general Foldable structure this should be semantically identical to,

foldl f z = foldl' f z . toList

intercalate :: [a] -> [[a]] -> [a] #

intercalate xs xss is equivalent to (concat (intersperse xs xss)). It inserts the list xs in between the lists in xss and concatenates the result.

catMaybes :: [Maybe a] -> [a] #

The catMaybes function takes a list of Maybes and returns a list of all the Just values.

Examples

Basic usage:

>>> catMaybes [Just 1, Nothing, Just 3]
[1,3]

When constructing a list of Maybe values, catMaybes can be used to return all of the "success" results (if the list is the result of a map, then mapMaybe would be more appropriate):

>>> import Text.Read ( readMaybe )
>>> [readMaybe x :: Maybe Int | x <- ["1", "Foo", "3"] ]
[Just 1,Nothing,Just 3]
>>> catMaybes $ [readMaybe x :: Maybe Int | x <- ["1", "Foo", "3"] ]
[1,3]

fromJust :: Maybe a -> a #

The fromJust function extracts the element out of a Just and throws an error if its argument is Nothing.

Examples

Basic usage:

>>> fromJust (Just 1)
1
>>> 2 * (fromJust (Just 10))
20
>>> 2 * (fromJust Nothing)
*** Exception: Maybe.fromJust: Nothing

fromMaybe :: a -> Maybe a -> a #

The fromMaybe function takes a default value and and Maybe value. If the Maybe is Nothing, it returns the default values; otherwise, it returns the value contained in the Maybe.

Examples

Basic usage:

>>> fromMaybe "" (Just "Hello, World!")
"Hello, World!"
>>> fromMaybe "" Nothing
""

Read an integer from a string using readMaybe. If we fail to parse an integer, we want to return 0 by default:

>>> import Text.Read ( readMaybe )
>>> fromMaybe 0 (readMaybe "5")
5
>>> fromMaybe 0 (readMaybe "")
0

(<>) :: Monoid m => m -> m -> m infixr 6 #

An infix synonym for mappend.

Since: 4.5.0.0

getDirectoryContents :: FilePath -> IO [FilePath] #

Similar to listDirectory, but always includes the special entries (. and ..). (This applies to Windows as well.)

The operation may fail with the same exceptions as listDirectory.

getArgs :: IO [String] #

Computation getArgs returns a list of the program's command line arguments (not including the program name).

(</>) :: FilePath -> FilePath -> FilePath infixr 5 #

Combine two paths with a path separator. If the second path starts with a path separator or a drive letter, then it returns the second. The intention is that readFile (dir </> file) will access the same file as setCurrentDirectory dir; readFile file.

Posix:   "/directory" </> "file.ext" == "/directory/file.ext"
Windows: "/directory" </> "file.ext" == "/directory\\file.ext"
         "directory" </> "/file.ext" == "/file.ext"
Valid x => (takeDirectory x </> takeFileName x) `equalFilePath` x

Combined:

Posix:   "/" </> "test" == "/test"
Posix:   "home" </> "bob" == "home/bob"
Posix:   "x:" </> "foo" == "x:/foo"
Windows: "C:\\foo" </> "bar" == "C:\\foo\\bar"
Windows: "home" </> "bob" == "home\\bob"

Not combined:

Posix:   "home" </> "/bob" == "/bob"
Windows: "home" </> "C:\\bob" == "C:\\bob"

Not combined (tricky):

On Windows, if a filepath starts with a single slash, it is relative to the root of the current drive. In [1], this is (confusingly) referred to as an absolute path. The current behavior of </> is to never combine these forms.

Windows: "home" </> "/bob" == "/bob"
Windows: "home" </> "\\bob" == "\\bob"
Windows: "C:\\home" </> "\\bob" == "\\bob"

On Windows, from [1]: "If a file name begins with only a disk designator but not the backslash after the colon, it is interpreted as a relative path to the current directory on the drive with the specified letter." The current behavior of </> is to never combine these forms.

Windows: "D:\\foo" </> "C:bar" == "C:bar"
Windows: "C:\\foo" </> "C:bar" == "C:bar"

(<.>) :: FilePath -> String -> FilePath infixr 7 #

Add an extension, even if there is already one there, equivalent to addExtension.

"/directory/path" <.> "ext" == "/directory/path.ext"
"/directory/path" <.> ".ext" == "/directory/path.ext"

withFile :: FilePath -> IOMode -> (Handle -> IO r) -> IO r #

withFile name mode act opens a file using openFile and passes the resulting handle to the computation act. The handle will be closed on exit from withFile, whether by normal termination or by raising an exception. If closing the handle raises an exception, then this exception will be raised by withFile rather than any exception raised by act.

hPutStr :: Handle -> String -> IO () #

Computation hPutStr hdl s writes the string s to the file or channel managed by hdl.

This operation may fail with:

hPutStrLn :: Handle -> String -> IO () #

The same as hPutStr, but adds a newline character.

printf :: PrintfType r => String -> r #

Format a variable number of arguments with the C-style formatting string. The return value is either String or (IO a) (which should be (IO '()'), but Haskell's type system makes this hard).

The format string consists of ordinary characters and conversion specifications, which specify how to format one of the arguments to printf in the output string. A format specification is introduced by the % character; this character can be self-escaped into the format string using %%. A format specification ends with a /format character/ that provides the primary information about how to format the value. The rest of the conversion specification is optional. In order, one may have flag characters, a width specifier, a precision specifier, and type-specific modifier characters.

Unlike C printf(3), the formatting of this printf is driven by the argument type; formatting is type specific. The types formatted by printf "out of the box" are:

printf is also extensible to support other types: see below.

A conversion specification begins with the character %, followed by zero or more of the following flags:

   -      left adjust (default is right adjust)
   +      always use a sign (+ or -) for signed conversions
   space  leading space for positive numbers in signed conversions
   0      pad with zeros rather than spaces
   #      use an \"alternate form\": see below

When both flags are given, - overrides 0 and + overrides space. A negative width specifier in a * conversion is treated as positive but implies the left adjust flag.

The "alternate form" for unsigned radix conversions is as in C printf(3):

   %o           prefix with a leading 0 if needed
   %x           prefix with a leading 0x if nonzero
   %X           prefix with a leading 0X if nonzero
   %b           prefix with a leading 0b if nonzero
   %[eEfFgG]    ensure that the number contains a decimal point

Any flags are followed optionally by a field width:

   num    field width
   *      as num, but taken from argument list

The field width is a minimum, not a maximum: it will be expanded as needed to avoid mutilating a value.

Any field width is followed optionally by a precision:

   .num   precision
   .      same as .0
   .*     as num, but taken from argument list

Negative precision is taken as 0. The meaning of the precision depends on the conversion type.

   Integral    minimum number of digits to show
   RealFloat   number of digits after the decimal point
   String      maximum number of characters

The precision for Integral types is accomplished by zero-padding. If both precision and zero-pad are given for an Integral field, the zero-pad is ignored.

Any precision is followed optionally for Integral types by a width modifier; the only use of this modifier being to set the implicit size of the operand for conversion of a negative operand to unsigned:

   hh     Int8
   h      Int16
   l      Int32
   ll     Int64
   L      Int64

The specification ends with a format character:

   c      character               Integral
   d      decimal                 Integral
   o      octal                   Integral
   x      hexadecimal             Integral
   X      hexadecimal             Integral
   b      binary                  Integral
   u      unsigned decimal        Integral
   f      floating point          RealFloat
   F      floating point          RealFloat
   g      general format float    RealFloat
   G      general format float    RealFloat
   e      exponent format float   RealFloat
   E      exponent format float   RealFloat
   s      string                  String
   v      default format          any type

The "%v" specifier is provided for all built-in types, and should be provided for user-defined type formatters as well. It picks a "best" representation for the given type. For the built-in types the "%v" specifier is converted as follows:

   c      Char
   u      other unsigned Integral
   d      other signed Integral
   g      RealFloat
   s      String

Mismatch between the argument types and the format string, as well as any other syntactic or semantic errors in the format string, will cause an exception to be thrown at runtime.

Note that the formatting for RealFloat types is currently a bit different from that of C printf(3), conforming instead to showEFloat, showFFloat and showGFloat (and their alternate versions showFFloatAlt and showGFloatAlt). This is hard to fix: the fixed versions would format in a backward-incompatible way. In any case the Haskell behavior is generally more sensible than the C behavior. A brief summary of some key differences:

  • Haskell printf never uses the default "6-digit" precision used by C printf.
  • Haskell printf treats the "precision" specifier as indicating the number of digits after the decimal point.
  • Haskell printf prints the exponent of e-format numbers without a gratuitous plus sign, and with the minimum possible number of digits.
  • Haskell printf will place a zero after a decimal point when possible.

Examples

  > printf "%d\n" (23::Int)
  23
  > printf "%s %s\n" "Hello" "World"
  Hello World
  > printf "%.2f\n" pi
  3.14