Haskell

Predefined types

Bounds of a Int

Bounds can be seen for instances of Bounded type class:

λ> minBound :: Int
-9223372036854775808
λ> maxBound :: Int
9223372036854775807


λ> maxBound :: Bool
True
λ> minBound :: Bool
False


λ> maxBound :: Word
18446744073709551615


λ> maxBound :: Float
<interactive>:5:1: error:
No instance for (Bounded Float) arising from a use of ‘maxBound’
In the expression: maxBound :: Float
      In an equation for ‘it’: it = maxBound :: Float

λ> maxBound :: Integer
<interactive>:6:1: error:
No instance for (Bounded Integer)
        arising from a use of ‘maxBound’
In the expression: maxBound :: Integer
      In an equation for ‘it’: it = maxBound :: Integer

Beyonds bounds, value will wrap around:

λ> (maxBound :: Int) + 1
-9223372036854775808

Symbols

<$> fmap Functor f => (a -> b) -> f a -> f b
<*> (apply) Applicative f => f (a -> b) -> f a -> f b
>>= (bind) Monad m => m a -> (a -> m b) -> m b
<│> (alternative) Alternative f => f a -> f a -> f b
<* Applicative f => f a -> f b -> f a
*> Applicative f => f a -> f b -> f b
>> ?? Monad m => m a -> m b -> m b
>< ??
<> ?? Semigroup a => a -> a -> a
. (compose) (b -> c) -> (a -> b) -> (a -> c)
$ (a -> b) -> a -> b

(>>)

a >> b is similar to a >>= b except that the value produced from a is ignored.

Kind of like:

a >>= b a >> b
do do
  x <- a   a
  b   b

Similar to *> as evident from type.

(<>)

Associative operator associated with a semigroup .

In the case of list:

λ> [1,2] <> [3]
[1,2,3]

because list is an instance of Semigroup:

λ> :i []
type [] :: * -> *
data [] a = [] | a : [a]
    -- Defined in `GHC.Types'
instance Alternative [] -- Defined in `GHC.Base'
instance Applicative [] -- Defined in `GHC.Base'
instance Eq a => Eq [a] -- Defined in `GHC.Classes'
instance Functor [] -- Defined in `GHC.Base'
instance Monad [] -- Defined in `GHC.Base'
instance Monoid [a] -- Defined in `GHC.Base'
instance Ord a => Ord [a] -- Defined in `GHC.Classes'
instance Semigroup [a] -- Defined in `GHC.Base'
instance Show a => Show [a] -- Defined in `GHC.Show'
instance Foldable [] -- Defined in `Data.Foldable'
instance Read a => Read [a] -- Defined in `GHC.Read'
instance MonadFail [] -- Defined in `Control.Monad.Fail'
instance Traversable [] -- Defined in `Data.Traversable'

ghci

http://dev.stephendiehl.com/hask/

For interactive haskell REPL.

Command Short Description
:reload :r Code reload
:type :t Type inspection
:kind :k Kind inspection
:info :i Information (can show definiton with constructors)
:print :p Print the expression
:edit :e Load file in system editor
:load :l Set the active Main module in the REPL
:module :m Add modules to imports
:add :ad Load a file into the REPL namespace
:instances :in Show instances of a typeclass
:browse :bro Browse all available symbols in the REPL namespace

Third party stuff

Parsec

Containers

Seq (as in list) type from Data.Sequence of 'containers' package.

<│ Add element to left end of a seq a -> Seq a -> Seq a
│> Add element to right end of a seq a -> Seq a -> Seq a
>< Concatenate two sequnces Seq a -> Seq a -> Seq a

Tools