| Safe Haskell | None |
|---|
Language.Fay.Prelude
- data Fay a
- data Char
- type String = [Char]
- data Integer
- data Double
- data Bool
- class Show a where
- class Read a
- data Maybe a
- read :: Read a => String -> a
- fromInteger :: Integer -> Double
- fromRational :: Ratio Integer -> Double
- (>>) :: Fay a -> Fay b -> Fay b
- (>>=) :: Fay a -> (a -> Fay b) -> Fay b
- (==) :: Eq a => a -> a -> Bool
- (/=) :: Eq a => a -> a -> Bool
- (+) :: Num a => a -> a -> a
- (*) :: Num a => a -> a -> a
- (-) :: Num a => a -> a -> a
- (>) :: Ord a => a -> a -> Bool
- (<) :: Ord a => a -> a -> Bool
- (||) :: Bool -> Bool -> Bool
- (&&) :: Bool -> Bool -> Bool
- fail :: String -> Fay a
- return :: a -> Fay a
- ($) :: (t1 -> t) -> t1 -> t
- snd :: (t, t1) -> t1
- fst :: (t, t1) -> t
- find :: (a -> Bool) -> [a] -> Maybe a
- any :: (t -> Bool) -> [t] -> Bool
- filter :: (a -> Bool) -> [a] -> [a]
- not :: Bool -> Bool
- null :: [t] -> Bool
- map :: (a -> b) -> [a] -> [b]
- nub :: Eq a => [a] -> [a]
- elem :: Eq a => a -> [a] -> Bool
- data Ordering
- sort :: Ord a => [a] -> [a]
- compare :: Ord a => a -> a -> Ordering
- sortBy :: (t -> t -> Ordering) -> [t] -> [t]
- insertBy :: (a -> a -> Ordering) -> a -> [a] -> [a]
- enumFrom :: Num a => a -> [a]
- zipWith :: (a -> b -> c) -> [a] -> [b] -> [c]
- zip :: [a] -> [b] -> [(a, b)]
- flip :: (t1 -> t2 -> t) -> t2 -> t1 -> t
- maybe :: t -> (t1 -> t) -> Maybe t1 -> t
- (.) :: (t1 -> t) -> (t2 -> t1) -> t2 -> t
- (++) :: [a] -> [a] -> [a]
- concat :: [[a]] -> [a]
- foldr :: (t -> t1 -> t1) -> t1 -> [t] -> t1
- foldl :: (t1 -> t -> t1) -> t1 -> [t] -> t1
- lookup :: Eq a1 => a1 -> [(a1, a)] -> Maybe a
- intersperse :: a -> [a] -> [a]
- prependToAll :: a -> [a] -> [a]
- intercalate :: [a] -> [[a]] -> [a]
- forM_ :: Monad m => [t] -> (t -> m a) -> m ()
Documentation
The JavaScript FFI interfacing monad.
data Char
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).
data Integer
Arbitrary-precision integers.
data Double
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.
data Bool
class Show a where
Conversion of values to readable Strings.
Minimal complete definition: showsPrec or show.
Derived instances of Show have the following properties, which
are compatible with derived instances of Read:
- The result of
showis 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
showsPrecwill produce infix applications of the constructor. - the representation will be enclosed in parentheses if the
precedence of the top-level constructor in
xis less thand(associativity is ignored). Thus, ifdis0then the result is never surrounded in parentheses; ifdis11it is always surrounded in parentheses, unless it is an atomic expression. - If the constructor is defined using record syntax, then
showwill 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)".
Methods
Instances
class Read a
Parsing of Strings, producing values.
Minimal complete definition: readsPrec (or, for GHC only, readPrec)
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
Readinstance 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
Readwill parse only the record-syntax form, and furthermore, the fields must be given in the same order as the original declaration. - The derived
Readinstance 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 98 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
Instances
| Read Bool | |
| Read Char | |
| Read Double | |
| Read Float | |
| Read Int | |
| Read Integer | |
| Read Ordering | |
| Read () | |
| Read ExitCode | |
| Read All | |
| Read Any | |
| Read Lexeme | |
| Read ByteString | |
| Read ByteString | |
| Read Arity | |
| Read Fixity | |
| Read Associativity | |
| Read a => Read [a] | |
| (Integral a, Read a) => Read (Ratio a) | |
| Read a => Read (Dual a) | |
| Read a => Read (Sum a) | |
| Read a => Read (Product a) | |
| Read a => Read (First a) | |
| Read a => Read (Last a) | |
| Read a => Read (Maybe a) | |
| (Read a, Read b) => Read (Either a b) | |
| (Read a, Read b) => Read (a, b) | |
| (Ix a, Read a, Read b) => Read (Array a b) | |
| (Read a, Read b, Read c) => Read (a, b, c) | |
| (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) |
data Maybe a
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.
Instances
| Monad Maybe | |
| Functor Maybe | |
| Typeable1 Maybe | |
| MonadPlus Maybe | |
| Applicative Maybe | |
| Alternative 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 |
| JSON a => JSON (Maybe a) |
The read function reads input from a string, which must be
completely consumed by the input process.
fromInteger :: Integer -> DoubleSource
Just to satisfy GHC.
fromRational :: Ratio Integer -> DoubleSource
Just to satisfy GHC.
intersperse :: a -> [a] -> [a]Source
prependToAll :: a -> [a] -> [a]Source
intercalate :: [a] -> [[a]] -> [a]Source