Int
vs Integer
:
Int
: fixed precisionInteger
: arbitrary precisionWord
: 'an unsigned integral type, with the same size as
Int' - Haskell language report 2010 ˡ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)
• of ‘maxBound’
arising from a use In the expression: maxBound :: Integer
• In an equation for ‘it’: it = maxBound :: Integer
Beyonds bounds, value will wrap around:
λ> (maxBound :: Int) + 1
-9223372036854775808
<$> |
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'
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) |
: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 |
<?>
: parser <?> err_msg
err_msg
shown when parsing with parser
failsSeq
(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 |