fay-0.1.2.0: A compiler for Fay, a Haskell subset that compiles to JavaScript.

Safe HaskellNone

Language.Fay.Prelude

Synopsis

Documentation

data Fay a Source

The JavaScript FFI interfacing monad.

Instances

Monad Fay 
Foreign a => Foreign (Fay a)

JS values are foreignable.

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).

type String = [Char]

A String is a list of characters. String constants in Haskell are values of type String.

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

Constructors

False 
True 

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 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 than d (associativity is ignored). Thus, if d is 0 then the result is never surrounded in parentheses; if d is 11 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,

  • show (Leaf 1 :^: Leaf 2 :^: Leaf 3) produces the string "Leaf 1 :^: (Leaf 2 :^: Leaf 3)".

Methods

show :: a -> String

A specialised variant of showsPrec, using precedence context zero, and returning an ordinary String.

Instances

Show Bool 
Show Char 
Show Double 
Show Float 
Show Int 
Show Integer 
Show Ordering 
Show () 
Show Handle 
Show HandleType 
Show DataType 
Show Constr 
Show DataRep 
Show ConstrRep 
Show Fixity 
Show BlockedIndefinitelyOnMVar 
Show BlockedIndefinitelyOnSTM 
Show Deadlock 
Show AssertionFailed 
Show AsyncException 
Show ArrayException 
Show ExitCode 
Show IOErrorType 
Show BufferMode 
Show Newline 
Show NewlineMode 
Show All 
Show Any 
Show MaskingState 
Show IOException 
Show SomeException 
Show ErrorCall 
Show ArithException 
Show TypeRep 
Show TyCon 
Show ByteString 
Show ByteString 
Show Arity 
Show Fixity 
Show Associativity 
Show LexContext 
Show ExtContext 
Show ModuleName 
Show SpecialCon 
Show QName 
Show Name 
Show IPName 
Show QOp 
Show Op 
Show CName 
Show Module 
Show ExportSpec 
Show ImportDecl 
Show ImportSpec 
Show Assoc 
Show Decl 
Show Annotation 
Show DataOrNew 
Show Binds 
Show IPBind 
Show Match 
Show QualConDecl 
Show ConDecl 
Show GadtDecl 
Show ClassDecl 
Show InstDecl 
Show BangType 
Show Rhs 
Show GuardedRhs 
Show Type 
Show TyVarBind 
Show Kind 
Show FunDep 
Show Asst 
Show Literal 
Show Exp 
Show XName 
Show XAttr 
Show Bracket 
Show Splice 
Show Safety 
Show CallConv 
Show ModulePragma 
Show Activation 
Show Rule 
Show RuleVar 
Show WarningText 
Show Pat 
Show PXAttr 
Show RPatOp 
Show RPat 
Show PatField 
Show Stmt 
Show QualStmt 
Show FieldUpdate 
Show Alt 
Show GuardedAlts 
Show GuardedAlt 
Show Boxed 
Show Tool 
Show SrcLoc 
Show SrcSpan 
Show SrcSpanInfo 
Show Value 
Show JsLit 
Show JsExp 
Show JsStmt 
Show CompileError 
Show CompileState 
Show CompileConfig 
Show ArgType 
Show a => Show [a] 
(Integral a, Show a) => Show (Ratio a) 
Show a => Show (Dual a) 
Show a => Show (Sum a) 
Show a => Show (Product a) 
Show a => Show (First a) 
Show a => Show (Last a) 
Show a => Show (Maybe a) 
Show a => Show (ParseResult a) 
Show l => Show (ModuleName l) 
Show l => Show (SpecialCon l) 
Show l => Show (QName l) 
Show l => Show (Name l) 
Show l => Show (IPName l) 
Show l => Show (QOp l) 
Show l => Show (Op l) 
Show l => Show (CName l) 
Show l => Show (Module l) 
Show l => Show (ModuleHead l) 
Show l => Show (ExportSpecList l) 
Show l => Show (ExportSpec l) 
Show l => Show (ImportDecl l) 
Show l => Show (ImportSpecList l) 
Show l => Show (ImportSpec l) 
Show l => Show (Assoc l) 
Show l => Show (Decl l) 
Show l => Show (Annotation l) 
Show l => Show (DataOrNew l) 
Show l => Show (DeclHead l) 
Show l => Show (InstHead l) 
Show l => Show (Deriving l) 
Show l => Show (Binds l) 
Show l => Show (IPBind l) 
Show l => Show (Match l) 
Show l => Show (QualConDecl l) 
Show l => Show (ConDecl l) 
Show l => Show (FieldDecl l) 
Show l => Show (GadtDecl l) 
Show l => Show (ClassDecl l) 
Show l => Show (InstDecl l) 
Show l => Show (BangType l) 
Show l => Show (Rhs l) 
Show l => Show (GuardedRhs l) 
Show l => Show (Type l) 
Show l => Show (TyVarBind l) 
Show l => Show (Kind l) 
Show l => Show (FunDep l) 
Show l => Show (Context l) 
Show l => Show (Asst l) 
Show l => Show (Literal l) 
Show l => Show (Exp l) 
Show l => Show (XName l) 
Show l => Show (XAttr l) 
Show l => Show (Bracket l) 
Show l => Show (Splice l) 
Show l => Show (Safety l) 
Show l => Show (CallConv l) 
Show l => Show (ModulePragma l) 
Show l => Show (Activation l) 
Show l => Show (Rule l) 
Show l => Show (RuleVar l) 
Show l => Show (WarningText l) 
Show l => Show (Pat l) 
Show l => Show (PXAttr l) 
Show l => Show (RPatOp l) 
Show l => Show (RPat l) 
Show l => Show (PatField l) 
Show l => Show (Stmt l) 
Show l => Show (QualStmt l) 
Show l => Show (FieldUpdate l) 
Show l => Show (Alt l) 
Show l => Show (GuardedAlts l) 
Show l => Show (GuardedAlt l) 
Show a => Show (Loc a) 
Show a => Show (Result a) 
Show a => Show (ParseStatus a) 
(Show a, Show b) => Show (Either a b) 
(Show a, Show b) => Show (a, b) 
(Show a, Show b, Show c) => Show (a, b, c) 
(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) 

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 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 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 BufferMode 
Read Newline 
Read NewlineMode 
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 Maybe a either contains a value of type a (represented as Just a), or it is empty (represented as Nothing). 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.

Constructors

Nothing 
Just a 

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 Maybe forming a Monoid according to http://en.wikipedia.org/wiki/Monoid: "Any semigroup S may be turned into a monoid simply by adjoining an element e not in S and defining e*e = e and e*s = s = s*e for all s ∈ S." Since there is no "Semigroup" typeclass providing just mappend, we use Monoid instead.

Default (Maybe a) 
JSON a => JSON (Maybe a) 

read :: Read a => String -> 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.

(>>) :: Fay a -> Fay b -> Fay bSource

(>>=) :: Fay a -> (a -> Fay b) -> Fay bSource

(==) :: 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

(>=) :: Ord a => a -> a -> Bool

(<=) :: Ord a => a -> a -> Bool

(/) :: Fractional a => a -> a -> a

fractional division

(||) :: Bool -> Bool -> Bool

Boolean "or"

(&&) :: Bool -> Bool -> Bool

Boolean "and"

return :: a -> Fay aSource

($) :: (t1 -> t) -> t1 -> tSource

snd :: (t, t1) -> t1Source

fst :: (t, t1) -> tSource

find :: (a -> Bool) -> [a] -> Maybe aSource

any :: (t -> Bool) -> [t] -> BoolSource

filter :: (a -> Bool) -> [a] -> [a]Source

null :: [t] -> BoolSource

map :: (a -> b) -> [a] -> [b]Source

nub :: Eq a => [a] -> [a]Source

elem :: Eq a => a -> [a] -> BoolSource

data Ordering Source

Constructors

GT 
LT 
EQ 

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

compare :: Ord a => a -> a -> OrderingSource

sortBy :: (t -> t -> Ordering) -> [t] -> [t]Source

insertBy :: (a -> a -> Ordering) -> a -> [a] -> [a]Source

enumFrom :: Num a => a -> [a]Source

zipWith :: (a -> b -> c) -> [a] -> [b] -> [c]Source

zip :: [a] -> [b] -> [(a, b)]Source

flip :: (t1 -> t2 -> t) -> t2 -> t1 -> tSource

maybe :: t -> (t1 -> t) -> Maybe t1 -> tSource

(.) :: (t1 -> t) -> (t2 -> t1) -> t2 -> tSource

(++) :: [a] -> [a] -> [a]Source

concat :: [[a]] -> [a]Source

foldr :: (t -> t1 -> t1) -> t1 -> [t] -> t1Source

foldl :: (t1 -> t -> t1) -> t1 -> [t] -> t1Source

lookup :: Eq a1 => a1 -> [(a1, a)] -> Maybe aSource

intersperse :: a -> [a] -> [a]Source

prependToAll :: a -> [a] -> [a]Source

intercalate :: [a] -> [[a]] -> [a]Source

forM_ :: Monad m => [t] -> (t -> m a) -> m ()Source