Safe Haskell | None |
---|---|
Language | Haskell98 |
- data Char :: *
- type String = [Char]
- data Double :: *
- data Int :: *
- data Integer :: *
- data Bool :: *
- class Read a
- class Show a
- class Eq a where
- (==) :: Eq a => a -> a -> Bool
- (/=) :: Eq a => a -> a -> Bool
- data Maybe a :: * -> *
- maybe :: t -> (t1 -> t) -> Maybe t1 -> t
- (>>=) :: Ptr (Fay a) -> Ptr (a -> Fay b) -> Ptr (Fay b)
- (>>) :: Ptr (Fay a) -> Ptr (Fay b) -> Ptr (Fay b)
- return :: a -> Fay a
- fail :: String -> Fay a
- when :: Bool -> Fay () -> Fay ()
- unless :: Bool -> Fay () -> Fay ()
- forM :: [a] -> (a -> Fay b) -> Fay [b]
- forM_ :: [a] -> (a -> Fay b) -> Fay ()
- mapM :: (a -> Fay b) -> [a] -> Fay [b]
- mapM_ :: (a -> Fay b) -> [a] -> Fay ()
- (=<<) :: (a -> Fay b) -> Fay a -> Fay b
- sequence :: [Fay a] -> Fay [a]
- sequence_ :: [Fay a] -> Fay ()
- void :: Fay a -> Fay ()
- (>=>) :: (a -> Fay b) -> (b -> Fay c) -> a -> Fay c
- (<=<) :: (b -> Fay c) -> (a -> Fay b) -> a -> Fay c
- (*) :: Num a => a -> a -> a
- (+) :: Num a => a -> a -> a
- (-) :: Num a => a -> a -> a
- class Eq a => Ord a where
- data Ordering :: *
- (<) :: Ord a => a -> a -> Bool
- (<=) :: Ord a => a -> a -> Bool
- (>) :: Ord a => a -> a -> Bool
- (>=) :: Ord a => a -> a -> Bool
- compare :: Ord a => a -> a -> Ordering
- succ :: Num a => a -> a
- pred :: Num a => a -> a
- enumFrom :: Num a => a -> [a]
- enumFromTo :: (Ord t, Num t) => t -> t -> [t]
- enumFromBy :: Num t => t -> t -> [t]
- enumFromThen :: Num t => t -> t -> [t]
- enumFromByTo :: (Ord t, Num t) => t -> t -> t -> [t]
- enumFromThenTo :: (Ord t, Num t) => t -> t -> t -> [t]
- (/) :: Fractional a => a -> a -> a
- fromIntegral :: (Num a, Num b) => Ptr a -> Ptr b
- fromInteger :: Num a => Ptr Integer -> Ptr a
- (&&) :: Bool -> Bool -> Bool
- (||) :: Bool -> Bool -> Bool
- not :: Bool -> Bool
- otherwise :: Bool
- show :: Automatic a -> String
- error :: String -> a
- undefined :: a
- data Either a b :: * -> * -> *
- either :: (a -> c) -> (b -> c) -> Either a b -> c
- until :: (a -> Bool) -> (a -> a) -> a -> a
- ($!) :: (a -> b) -> a -> b
- seq :: a -> b -> b
- const :: a -> b -> a
- id :: a -> a
- (.) :: (t1 -> t) -> (t2 -> t1) -> t2 -> t
- ($) :: (t1 -> t) -> t1 -> t
- flip :: (t1 -> t2 -> t) -> t2 -> t1 -> t
- curry :: ((a, b) -> c) -> a -> b -> c
- uncurry :: (a -> b -> c) -> (a, b) -> c
- snd :: (t, t1) -> t1
- fst :: (t, t1) -> t
- div :: Int -> Int -> Int
- mod :: Int -> Int -> Int
- divMod :: Int -> Int -> (Int, Int)
- min :: Num a => a -> a -> a
- max :: Num a => a -> a -> a
- recip :: Double -> Double
- negate :: Num a => a -> a
- abs :: (Num a, Ord a) => a -> a
- signum :: (Num a, Ord a) => a -> a
- pi :: Double
- exp :: Double -> Double
- sqrt :: Double -> Double
- log :: Double -> Double
- (**) :: Double -> Double -> Double
- (^^) :: Double -> Int -> Double
- unsafePow :: (Num a, Num b) => a -> b -> a
- (^) :: Num a => a -> Int -> a
- logBase :: Double -> Double -> Double
- sin :: Double -> Double
- tan :: Double -> Double
- cos :: Double -> Double
- asin :: Double -> Double
- atan :: Double -> Double
- acos :: Double -> Double
- sinh :: Double -> Double
- tanh :: Double -> Double
- cosh :: Double -> Double
- asinh :: Double -> Double
- atanh :: Double -> Double
- acosh :: Double -> Double
- properFraction :: Double -> (Int, Double)
- truncate :: Double -> Int
- round :: Double -> Int
- ceiling :: Double -> Int
- floor :: Double -> Int
- subtract :: Num a => a -> a -> a
- even :: Int -> Bool
- odd :: Int -> Bool
- gcd :: Int -> Int -> Int
- quot :: Int -> Int -> Int
- quot' :: Int -> Int -> Int
- quotRem :: Int -> Int -> (Int, Int)
- rem :: Int -> Int -> Int
- rem' :: Int -> Int -> Int
- lcm :: Int -> Int -> Int
- find :: (a -> Bool) -> [a] -> Maybe a
- filter :: (a -> Bool) -> [a] -> [a]
- null :: [t] -> Bool
- map :: (a -> b) -> [a] -> [b]
- nub :: Eq a => [a] -> [a]
- nub' :: Eq a => [a] -> [a] -> [a]
- elem :: Eq a => a -> [a] -> Bool
- notElem :: Eq a => a -> [a] -> Bool
- sort :: Ord a => [a] -> [a]
- sortBy :: (t -> t -> Ordering) -> [t] -> [t]
- insertBy :: (a -> a -> Ordering) -> a -> [a] -> [a]
- conc :: [a] -> [a] -> [a]
- concat :: [[a]] -> [a]
- concatMap :: (a -> [b]) -> [a] -> [b]
- foldr :: (t -> t1 -> t1) -> t1 -> [t] -> t1
- foldr1 :: (a -> a -> a) -> [a] -> a
- foldl :: (t1 -> t -> t1) -> t1 -> [t] -> t1
- foldl1 :: (a -> a -> a) -> [a] -> a
- (++) :: [a] -> [a] -> [a]
- (!!) :: [a] -> Int -> a
- head :: [a] -> a
- tail :: [a] -> [a]
- init :: [a] -> [a]
- last :: [a] -> a
- iterate :: (a -> a) -> a -> [a]
- repeat :: a -> [a]
- replicate :: Int -> a -> [a]
- cycle :: [a] -> [a]
- take :: Int -> [a] -> [a]
- drop :: Int -> [a] -> [a]
- splitAt :: Int -> [a] -> ([a], [a])
- takeWhile :: (a -> Bool) -> [a] -> [a]
- dropWhile :: (a -> Bool) -> [a] -> [a]
- span :: (a -> Bool) -> [a] -> ([a], [a])
- break :: (a -> Bool) -> [a] -> ([a], [a])
- zipWith :: (a -> b -> c) -> [a] -> [b] -> [c]
- zipWith3 :: (a -> b -> c -> d) -> [a] -> [b] -> [c] -> [d]
- zip :: [a] -> [b] -> [(a, b)]
- zip3 :: [a] -> [b] -> [c] -> [(a, b, c)]
- unzip :: [(a, b)] -> ([a], [b])
- unzip3 :: [(a, b, c)] -> ([a], [b], [c])
- lines :: String -> [String]
- unlines :: [String] -> String
- words :: String -> [String]
- unwords :: [String] -> String
- and :: [Bool] -> Bool
- or :: [Bool] -> Bool
- any :: (a -> Bool) -> [a] -> Bool
- all :: (a -> Bool) -> [a] -> Bool
- intersperse :: a -> [a] -> [a]
- prependToAll :: a -> [a] -> [a]
- intercalate :: [a] -> [[a]] -> [a]
- maximum :: Num a => [a] -> a
- minimum :: Num a => [a] -> a
- product :: Num a => [a] -> a
- sum :: Num a => [a] -> a
- scanl :: (a -> b -> a) -> a -> [b] -> [a]
- scanl1 :: (a -> a -> a) -> [a] -> [a]
- scanr :: (a -> b -> b) -> b -> [a] -> [b]
- scanr1 :: (a -> a -> a) -> [a] -> [a]
- lookup :: Eq a1 => a1 -> [(a1, a)] -> Maybe a
- length :: [a] -> Int
- length' :: Int -> [a] -> Int
- reverse :: [a] -> [a]
- print :: Automatic a -> Fay ()
- putStrLn :: String -> Fay ()
- ifThenElse :: Bool -> t -> t -> t
- data Fay a :: * -> *
Documentation
The character type Char
is an enumeration whose values represent
Unicode (or equivalently ISO/IEC 10646) characters (see
http://www.unicode.org/ for details). This set extends the ISO 8859-1
(Latin-1) character set (the first 256 characters), which is itself an extension
of the ASCII character set (the first 128 characters). A character literal in
Haskell has type Char
.
To convert a Char
to or from the corresponding Int
value defined
by Unicode, use toEnum
and fromEnum
from the
Enum
class respectively (or equivalently ord
and chr
).
Bounded Char | |
Enum Char | |
Eq Char | |
Data Char | |
Ord Char | |
Read Char | |
Show Char | |
ModName String | |
ErrorList Char | |
Functor (URec Char) | |
Generic1 (URec Char) | |
Eq (URec Char p) | |
Ord (URec Char p) | |
Show (URec Char p) | |
Generic (URec Char p) | |
data URec Char | Used for marking occurrences of |
type Rep1 (URec Char) | |
type Rep (URec Char p) | |
Double-precision floating point numbers. It is desirable that this type be at least equal in range and precision to the IEEE double-precision type.
Eq Double | |
Floating Double | |
Data Double | |
Ord Double | |
Read Double | |
RealFloat Double | |
Functor (URec Double) | |
Generic1 (URec Double) | |
Eq (URec Double p) | |
Ord (URec Double p) | |
Show (URec Double p) | |
Generic (URec Double p) | |
data URec Double | Used for marking occurrences of |
type Rep1 (URec Double) | |
type Rep (URec Double p) | |
Parsing of String
s, producing values.
Derived instances of Read
make the following assumptions, which
derived instances of Show
obey:
- If the constructor is defined to be an infix operator, then the
derived
Read
instance will parse only infix applications of the constructor (not the prefix form). - Associativity is not used to reduce the occurrence of parentheses, although precedence may be.
- If the constructor is defined using record syntax, the derived
Read
will parse only the record-syntax form, and furthermore, the fields must be given in the same order as the original declaration. - The derived
Read
instance allows arbitrary Haskell whitespace between tokens of the input string. Extra parentheses are also allowed.
For example, given the declarations
infixr 5 :^: data Tree a = Leaf a | Tree a :^: Tree a
the derived instance of Read
in Haskell 2010 is equivalent to
instance (Read a) => Read (Tree a) where readsPrec d r = readParen (d > app_prec) (\r -> [(Leaf m,t) | ("Leaf",s) <- lex r, (m,t) <- readsPrec (app_prec+1) s]) r ++ readParen (d > up_prec) (\r -> [(u:^:v,w) | (u,s) <- readsPrec (up_prec+1) r, (":^:",t) <- lex s, (v,w) <- readsPrec (up_prec+1) t]) r where app_prec = 10 up_prec = 5
Note that right-associativity of :^:
is unused.
The derived instance in GHC is equivalent to
instance (Read a) => Read (Tree a) where readPrec = parens $ (prec app_prec $ do Ident "Leaf" <- lexP m <- step readPrec return (Leaf m)) +++ (prec up_prec $ do u <- step readPrec Symbol ":^:" <- lexP v <- step readPrec return (u :^: v)) where app_prec = 10 up_prec = 5 readListPrec = readListPrecDefault
Read Bool | |
Read Char | |
Read Double | |
Read Float | |
Read Int | |
Read Integer | |
Read Ordering | |
Read Word | |
Read () | |
Read Version | |
Read Fixity | |
Read Associativity | |
Read SourceUnpackedness | |
Read SourceStrictness | |
Read DecidedStrictness | |
Read Lexeme | |
Read GeneralCategory | |
Read a => Read [a] | |
Read a => Read (Maybe a) | |
(Integral a, Read a) => Read (Ratio a) | |
Read (V1 p) | |
Read (U1 p) | |
Read p => Read (Par1 p) | |
Read a => Read (Identity a) | This instance would be equivalent to the derived instances of the
|
(Read b, Read a) => Read (Either a b) | |
Read (f p) => Read (Rec1 f p) | |
(Read a, Read b) => Read (a, b) | |
(Ix a, Read a, Read b) => Read (Array a b) | |
Read (Proxy k s) | |
Read c => Read (K1 i c p) | |
(Read (g p), Read (f p)) => Read ((:+:) f g p) | |
(Read (g p), Read (f p)) => Read ((:*:) f g p) | |
Read (f (g p)) => Read ((:.:) f g p) | |
(Read a, Read b, Read c) => Read (a, b, c) | |
(~) k a b => Read ((:~:) k a b) | |
(Read e, Read1 m, Read a) => Read (ErrorT e m a) | |
Read (f p) => Read (M1 i c f p) | |
(Read a, Read b, Read c, Read d) => Read (a, b, c, d) | |
(Read a, Read b, Read c, Read d, Read e) => Read (a, b, c, d, e) | |
(Read a, Read b, Read c, Read d, Read e, Read f) => Read (a, b, c, d, e, f) | |
(Read a, Read b, Read c, Read d, Read e, Read f, Read g) => Read (a, b, c, d, e, f, g) | |
(Read a, Read b, Read c, Read d, Read e, Read f, Read g, Read h) => Read (a, b, c, d, e, f, g, h) | |
(Read a, Read b, Read c, Read d, Read e, Read f, Read g, Read h, Read i) => Read (a, b, c, d, e, f, g, h, i) | |
(Read a, Read b, Read c, Read d, Read e, Read f, Read g, Read h, Read i, Read j) => Read (a, b, c, d, e, f, g, h, i, j) | |
(Read a, Read b, Read c, Read d, Read e, Read f, Read g, Read h, Read i, Read j, Read k) => Read (a, b, c, d, e, f, g, h, i, j, k) | |
(Read a, Read b, Read c, Read d, Read e, Read f, Read g, Read h, Read i, Read j, Read k, Read l) => Read (a, b, c, d, e, f, g, h, i, j, k, l) | |
(Read a, Read b, Read c, Read d, Read e, Read f, Read g, Read h, Read i, Read j, Read k, Read l, Read m) => Read (a, b, c, d, e, f, g, h, i, j, k, l, m) | |
(Read a, Read b, Read c, Read d, Read e, Read f, Read g, Read h, Read i, Read j, Read k, Read l, Read m, Read n) => Read (a, b, c, d, e, f, g, h, i, j, k, l, m, n) | |
(Read a, Read b, Read c, Read d, Read e, Read f, Read g, Read h, Read i, Read j, Read k, Read l, Read m, Read n, Read o) => Read (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) | |
Conversion of values to readable String
s.
Derived instances of Show
have the following properties, which
are compatible with derived instances of Read
:
- The result of
show
is a syntactically correct Haskell expression containing only constants, given the fixity declarations in force at the point where the type is declared. It contains only the constructor names defined in the data type, parentheses, and spaces. When labelled constructor fields are used, braces, commas, field names, and equal signs are also used. - If the constructor is defined to be an infix operator, then
showsPrec
will produce infix applications of the constructor. - the representation will be enclosed in parentheses if the
precedence of the top-level constructor in
x
is less thand
(associativity is ignored). Thus, ifd
is0
then the result is never surrounded in parentheses; ifd
is11
it is always surrounded in parentheses, unless it is an atomic expression. - If the constructor is defined using record syntax, then
show
will produce the record-syntax form, with the fields given in the same order as the original declaration.
For example, given the declarations
infixr 5 :^: data Tree a = Leaf a | Tree a :^: Tree a
the derived instance of Show
is equivalent to
instance (Show a) => Show (Tree a) where showsPrec d (Leaf m) = showParen (d > app_prec) $ showString "Leaf " . showsPrec (app_prec+1) m where app_prec = 10 showsPrec d (u :^: v) = showParen (d > up_prec) $ showsPrec (up_prec+1) u . showString " :^: " . showsPrec (up_prec+1) v where up_prec = 5
Note that right-associativity of :^:
is ignored. For example,
produces the stringshow
(Leaf 1 :^: Leaf 2 :^: Leaf 3)"Leaf 1 :^: (Leaf 2 :^: Leaf 3)"
.
Show Bool | |
Show Char | |
Show Int | |
Show Integer | |
Show Ordering | |
Show Word | |
Show CallStack | |
Show TypeRep | |
Show () | |
Show TyCon | |
Show Module | |
Show TrName | |
Show Version | |
Show DataType | |
Show Constr | |
Show DataRep | |
Show ConstrRep | |
Show Fixity | |
Show Fixity | |
Show Associativity | |
Show SourceUnpackedness | |
Show SourceStrictness | |
Show DecidedStrictness | |
Show SrcLoc | |
Show ModuleName | |
Show Symbols | |
Show GName | |
Show OrigName | |
Show CompileState | |
Show CompileWriter | |
Show Rational # | |
Show Day # | |
Show UTCTime # | |
Show a => Show [a] | |
Show a => Show (Maybe a) | |
Show a => Show (Ratio a) | |
Show (Ptr a) | |
Show (FunPtr a) | |
Show (V1 p) | |
Show (U1 p) | |
Show p => Show (Par1 p) | |
Show a => Show (Identity a) | This instance would be equivalent to the derived instances of the
|
Show l => Show (NameInfo l) | |
Show l => Show (Error l) | |
Show name => Show (SymValueInfo name) | |
Show name => Show (SymTypeInfo name) | |
Show l => Show (Scoped l) | |
Show l => Show (PragmasAndModuleName l) | |
Show l => Show (PragmasAndModuleHead l) | |
Show l => Show (ModuleHeadAndImports l) | |
Show a => Show (NonGreedy a) | |
Show a => Show (ListOf a) | |
(Show b, Show a) => Show (Either a b) | |
Show (f p) => Show (Rec1 f p) | |
Show (URec Char p) | |
Show (URec Double p) | |
Show (URec Float p) | |
Show (URec Int p) | |
Show (URec Word p) | |
(Show a, Show b) => Show (a, b) | |
Show (Proxy k s) | |
Show c => Show (K1 i c p) | |
(Show (g p), Show (f p)) => Show ((:+:) f g p) | |
(Show (g p), Show (f p)) => Show ((:*:) f g p) | |
Show (f (g p)) => Show ((:.:) f g p) | |
(Show a, Show b, Show c) => Show (a, b, c) | |
Show ((:~:) k a b) | |
(Show e, Show1 m, Show a) => Show (ErrorT e m a) | |
Show (f p) => Show (M1 i c f p) | |
(Show a, Show b, Show c, Show d) => Show (a, b, c, d) | |
(Show a, Show b, Show c, Show d, Show e) => Show (a, b, c, d, e) | |
(Show a, Show b, Show c, Show d, Show e, Show f) => Show (a, b, c, d, e, f) | |
(Show a, Show b, Show c, Show d, Show e, Show f, Show g) => Show (a, b, c, d, e, f, g) | |
(Show a, Show b, Show c, Show d, Show e, Show f, Show g, Show h) => Show (a, b, c, d, e, f, g, h) | |
(Show a, Show b, Show c, Show d, Show e, Show f, Show g, Show h, Show i) => Show (a, b, c, d, e, f, g, h, i) | |
(Show a, Show b, Show c, Show d, Show e, Show f, Show g, Show h, Show i, Show j) => Show (a, b, c, d, e, f, g, h, i, j) | |
(Show a, Show b, Show c, Show d, Show e, Show f, Show g, Show h, Show i, Show j, Show k) => Show (a, b, c, d, e, f, g, h, i, j, k) | |
(Show a, Show b, Show c, Show d, Show e, Show f, Show g, Show h, Show i, Show j, Show k, Show l) => Show (a, b, c, d, e, f, g, h, i, j, k, l) | |
(Show a, Show b, Show c, Show d, Show e, Show f, Show g, Show h, Show i, Show j, Show k, Show l, Show m) => Show (a, b, c, d, e, f, g, h, i, j, k, l, m) | |
(Show a, Show b, Show c, Show d, Show e, Show f, Show g, Show h, Show i, Show j, Show k, Show l, Show m, Show n) => Show (a, b, c, d, e, f, g, h, i, j, k, l, m, n) | |
(Show a, Show b, Show c, Show d, Show e, Show f, Show g, Show h, Show i, Show j, Show k, Show l, Show m, Show n, Show o) => Show (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) | |
The Eq
class defines equality (==
) and inequality (/=
).
All the basic datatypes exported by the Prelude are instances of Eq
,
and Eq
may be derived for any datatype whose constituents are also
instances of Eq
.
Eq Bool | |
Eq Char | |
Eq Double | |
Eq Float | |
Eq Int | |
Eq Integer | |
Eq Ordering | |
Eq Word | |
Eq TypeRep | |
Eq () | |
Eq TyCon | |
Eq Version | |
Eq BigNat | |
Eq SpecConstrAnnotation | |
Eq Constr | Equality of constructors |
Eq DataRep | |
Eq ConstrRep | |
Eq Fixity | |
Eq Fixity | |
Eq Associativity | |
Eq SourceUnpackedness | |
Eq SourceStrictness | |
Eq DecidedStrictness | |
Eq SrcLoc | |
Eq ModuleName | |
Eq Symbols | |
Eq GName | |
Eq OrigName | |
Eq Text # | |
Eq Day # | |
Eq UTCTime # | |
Eq a => Eq [a] | |
Eq a => Eq (Maybe a) | |
Eq a => Eq (Ratio a) | |
Eq (Ptr a) | |
Eq (FunPtr a) | |
Eq (V1 p) | |
Eq (U1 p) | |
Eq p => Eq (Par1 p) | |
Eq a => Eq (Identity a) | |
Eq l => Eq (NameInfo l) | |
Eq l => Eq (Error l) | |
Eq name => Eq (SymValueInfo name) | |
Eq name => Eq (SymTypeInfo name) | |
Eq l => Eq (Scoped l) | |
Eq l => Eq (PragmasAndModuleName l) | |
Eq l => Eq (PragmasAndModuleHead l) | |
Eq l => Eq (ModuleHeadAndImports l) | |
Eq a => Eq (NonGreedy a) | |
Eq a => Eq (ListOf a) | |
(Eq b, Eq a) => Eq (Either a b) | |
Eq (f p) => Eq (Rec1 f p) | |
Eq (URec Char p) | |
Eq (URec Double p) | |
Eq (URec Float p) | |
Eq (URec Int p) | |
Eq (URec Word p) | |
Eq (URec (Ptr ()) p) | |
(Eq a, Eq b) => Eq (a, b) | |
Eq (Proxy k s) | |
Eq c => Eq (K1 i c p) | |
(Eq (g p), Eq (f p)) => Eq ((:+:) f g p) | |
(Eq (g p), Eq (f p)) => Eq ((:*:) f g p) | |
Eq (f (g p)) => Eq ((:.:) f g p) | |
(Eq a, Eq b, Eq c) => Eq (a, b, c) | |
Eq ((:~:) k a b) | |
(Eq e, Eq1 m, Eq a) => Eq (ErrorT e m a) | |
Eq (f p) => Eq (M1 i c f p) | |
(Eq a, Eq b, Eq c, Eq d) => Eq (a, b, c, d) | |
(Eq a, Eq b, Eq c, Eq d, Eq e) => Eq (a, b, c, d, e) | |
(Eq a, Eq b, Eq c, Eq d, Eq e, Eq f) => Eq (a, b, c, d, e, f) | |
(Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g) => Eq (a, b, c, d, e, f, g) | |
(Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g, Eq h) => Eq (a, b, c, d, e, f, g, h) | |
(Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g, Eq h, Eq i) => Eq (a, b, c, d, e, f, g, h, i) | |
(Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g, Eq h, Eq i, Eq j) => Eq (a, b, c, d, e, f, g, h, i, j) | |
(Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g, Eq h, Eq i, Eq j, Eq k) => Eq (a, b, c, d, e, f, g, h, i, j, k) | |
(Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g, Eq h, Eq i, Eq j, Eq k, Eq l) => Eq (a, b, c, d, e, f, g, h, i, j, k, l) | |
(Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g, Eq h, Eq i, Eq j, Eq k, Eq l, Eq m) => Eq (a, b, c, d, e, f, g, h, i, j, k, l, m) | |
(Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g, Eq h, Eq i, Eq j, Eq k, Eq l, Eq m, Eq n) => Eq (a, b, c, d, e, f, g, h, i, j, k, l, m, n) | |
(Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g, Eq h, Eq i, Eq j, Eq k, Eq l, Eq m, Eq n, Eq o) => Eq (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) | |
The Maybe
type encapsulates an optional value. A value of type
either contains a value of type Maybe
aa
(represented as
),
or it is empty (represented as Just
aNothing
). Using Maybe
is a good way to
deal with errors or exceptional cases without resorting to drastic
measures such as error
.
The Maybe
type is also a monad. It is a simple kind of error
monad, where all errors are represented by Nothing
. A richer
error monad can be built using the Either
type.
Monad Maybe | |
Functor Maybe | |
Applicative Maybe | |
Generic1 Maybe | |
Alternative Maybe | |
MonadPlus Maybe | |
Eq1 Maybe | |
Ord1 Maybe | |
Read1 Maybe | |
Show1 Maybe | |
Eq a => Eq (Maybe a) | |
Data a => Data (Maybe a) | |
Ord a => Ord (Maybe a) | |
Read a => Read (Maybe a) | |
Show a => Show (Maybe a) | |
Generic (Maybe a) | |
Monoid a => Monoid (Maybe a) | Lift a semigroup into |
SingI (Maybe a) (Nothing a) | |
SingKind a (KProxy a) => SingKind (Maybe a) (KProxy (Maybe a)) | |
SingI a a1 => SingI (Maybe a) (Just a a1) | |
type Rep1 Maybe | |
type Rep (Maybe a) | |
data Sing (Maybe a) | |
type (==) (Maybe k) a b | |
type DemoteRep (Maybe a) (KProxy (Maybe a)) | |
sequence :: [Fay a] -> Fay [a] Source #
Evaluate each action in the sequence from left to right, and collect the results.
enumFromTo :: (Ord t, Num t) => t -> t -> [t] Source #
enumFromBy :: Num t => t -> t -> [t] Source #
enumFromThen :: Num t => t -> t -> [t] Source #
enumFromByTo :: (Ord t, Num t) => t -> t -> t -> [t] Source #
enumFromThenTo :: (Ord t, Num t) => t -> t -> t -> [t] Source #
fromIntegral :: (Num a, Num b) => Ptr a -> Ptr b Source #
fromInteger :: Num a => Ptr Integer -> Ptr a Source #
data Either a b :: * -> * -> * #
The Either
type represents values with two possibilities: a value of
type
is either Either
a b
or Left
a
.Right
b
The Either
type is sometimes used to represent a value which is
either correct or an error; by convention, the Left
constructor is
used to hold an error value and the Right
constructor is used to
hold a correct value (mnemonic: "right" also means "correct").
Examples
The type
is the type of values which can be either
a Either
String
Int
String
or an Int
. The Left
constructor can be used only on
String
s, and the Right
constructor can be used only on Int
s:
>>>
let s = Left "foo" :: Either String Int
>>>
s
Left "foo">>>
let n = Right 3 :: Either String Int
>>>
n
Right 3>>>
:type s
s :: Either String Int>>>
:type n
n :: Either String Int
The fmap
from our Functor
instance will ignore Left
values, but
will apply the supplied function to values contained in a Right
:
>>>
let s = Left "foo" :: Either String Int
>>>
let n = Right 3 :: Either String Int
>>>
fmap (*2) s
Left "foo">>>
fmap (*2) n
Right 6
The Monad
instance for Either
allows us to chain together multiple
actions which may fail, and fail overall if any of the individual
steps failed. First we'll write a function that can either parse an
Int
from a Char
, or fail.
>>>
import Data.Char ( digitToInt, isDigit )
>>>
:{
let parseEither :: Char -> Either String Int parseEither c | isDigit c = Right (digitToInt c) | otherwise = Left "parse error">>>
:}
The following should work, since both '1'
and '2'
can be
parsed as Int
s.
>>>
:{
let parseMultiple :: Either String Int parseMultiple = do x <- parseEither '1' y <- parseEither '2' return (x + y)>>>
:}
>>>
parseMultiple
Right 3
But the following should fail overall, since the first operation where
we attempt to parse 'm'
as an Int
will fail:
>>>
:{
let parseMultiple :: Either String Int parseMultiple = do x <- parseEither 'm' y <- parseEither '2' return (x + y)>>>
:}
>>>
parseMultiple
Left "parse error"
Eq2 Either | |
Ord2 Either | |
Read2 Either | |
Show2 Either | |
Monad (Either e) | |
Functor (Either a) | |
Applicative (Either e) | |
Generic1 (Either a) | |
Eq a => Eq1 (Either a) | |
Ord a => Ord1 (Either a) | |
Read a => Read1 (Either a) | |
Show a => Show1 (Either a) | |
(Eq b, Eq a) => Eq (Either a b) | |
(Data a, Data b) => Data (Either a b) | |
(Ord b, Ord a) => Ord (Either a b) | |
(Read b, Read a) => Read (Either a b) | |
(Show b, Show a) => Show (Either a b) | |
Generic (Either a b) | |
type Rep1 (Either a) | |
type Rep (Either a b) | |
type (==) (Either k k1) a b | |
The value of seq a b
is bottom if a
is bottom, and
otherwise equal to b
. seq
is usually introduced to
improve performance by avoiding unneeded laziness.
A note on evaluation order: the expression seq a b
does
not guarantee that a
will be evaluated before b
.
The only guarantee given by seq
is that the both a
and b
will be evaluated before seq
returns a value.
In particular, this means that b
may be evaluated before
a
. If you need to guarantee a specific order of evaluation,
you must use the function pseq
from the "parallel" package.
properFraction :: Double -> (Int, Double) Source #
Implemented in Fay, not fast.
intersperse :: a -> [a] -> [a] Source #
prependToAll :: a -> [a] -> [a] Source #
intercalate :: [a] -> [[a]] -> [a] Source #
ifThenElse :: Bool -> t -> t -> t Source #
Default definition for using RebindableSyntax.