curry-base-0.4.2: Functions for manipulating Curry programs

Copyright(c) 2003, Michael Hanus 2004, Martin Engelke 2005, Bernd Brassel 2009, Bernd Brassel 2012, Björn Peemöller
LicenseBSD-3-clause
Maintainerbjp@informatik.uni-kiel.de
Stabilityexperimental
Portabilitynon-portable (DeriveDataTypeable)
Safe HaskellNone
LanguageHaskell2010

Curry.ExtendedFlat.Type

Contents

Description

This is the extended version of FlatCurry, containing part calls for constructors, source references and typed expressions.

Synopsis

Representation of qualified names and variables

data SrcRef Source #

A pointer to the origin

Instances

Eq SrcRef Source # 

Methods

(==) :: SrcRef -> SrcRef -> Bool #

(/=) :: SrcRef -> SrcRef -> Bool #

Data SrcRef Source # 

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> SrcRef -> c SrcRef #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c SrcRef #

toConstr :: SrcRef -> Constr #

dataTypeOf :: SrcRef -> DataType #

dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c SrcRef) #

dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c SrcRef) #

gmapT :: (forall b. Data b => b -> b) -> SrcRef -> SrcRef #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> SrcRef -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> SrcRef -> r #

gmapQ :: (forall d. Data d => d -> u) -> SrcRef -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> SrcRef -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> SrcRef -> m SrcRef #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> SrcRef -> m SrcRef #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> SrcRef -> m SrcRef #

Ord SrcRef Source # 
Read SrcRef Source # 
Show SrcRef Source # 
Pretty SrcRef Source # 

data QName Source #

Qualified names.

In FlatCurry all names are qualified to avoid name clashes. The first component is the module name and the second component the unqualified name as it occurs in the source program.

The additional information about source references and types should be invisible for the normal usage of QName.

Constructors

QName 

Fields

Instances

Eq QName Source # 

Methods

(==) :: QName -> QName -> Bool #

(/=) :: QName -> QName -> Bool #

Data QName Source # 

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> QName -> c QName #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c QName #

toConstr :: QName -> Constr #

dataTypeOf :: QName -> DataType #

dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c QName) #

dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c QName) #

gmapT :: (forall b. Data b => b -> b) -> QName -> QName #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> QName -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> QName -> r #

gmapQ :: (forall d. Data d => d -> u) -> QName -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> QName -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> QName -> m QName #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> QName -> m QName #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> QName -> m QName #

Ord QName Source # 

Methods

compare :: QName -> QName -> Ordering #

(<) :: QName -> QName -> Bool #

(<=) :: QName -> QName -> Bool #

(>) :: QName -> QName -> Bool #

(>=) :: QName -> QName -> Bool #

max :: QName -> QName -> QName #

min :: QName -> QName -> QName #

Read QName Source # 
Show QName Source # 

Methods

showsPrec :: Int -> QName -> ShowS #

show :: QName -> String #

showList :: [QName] -> ShowS #

qnOf :: QName -> (String, String) Source #

Select the module name and the identifier from a qualified name

mkQName :: (String, String) -> QName Source #

Construct a qualified name from a module name and an identifier

data VarIndex Source #

Representation of variables. The additional information should be invisible for the normal usage.

Constructors

VarIndex 

Fields

Instances

Eq VarIndex Source # 
Data VarIndex Source # 

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> VarIndex -> c VarIndex #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c VarIndex #

toConstr :: VarIndex -> Constr #

dataTypeOf :: VarIndex -> DataType #

dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c VarIndex) #

dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c VarIndex) #

gmapT :: (forall b. Data b => b -> b) -> VarIndex -> VarIndex #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> VarIndex -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> VarIndex -> r #

gmapQ :: (forall d. Data d => d -> u) -> VarIndex -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> VarIndex -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> VarIndex -> m VarIndex #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> VarIndex -> m VarIndex #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> VarIndex -> m VarIndex #

Num VarIndex Source # 
Ord VarIndex Source # 
Read VarIndex Source # 
Show VarIndex Source # 

mkIdx :: Int -> VarIndex Source #

Construct a VarIndex

incVarIndex :: VarIndex -> Int -> VarIndex Source #

Increase the index of a variable by the given number

Data types for FlatCurry

data Visibility Source #

Visibility of various entities.

Constructors

Public

public (exported) entity

Private

private entity

Instances

Eq Visibility Source # 
Data Visibility Source # 

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Visibility -> c Visibility #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Visibility #

toConstr :: Visibility -> Constr #

dataTypeOf :: Visibility -> DataType #

dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c Visibility) #

dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Visibility) #

gmapT :: (forall b. Data b => b -> b) -> Visibility -> Visibility #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Visibility -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Visibility -> r #

gmapQ :: (forall d. Data d => d -> u) -> Visibility -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Visibility -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Visibility -> m Visibility #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Visibility -> m Visibility #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Visibility -> m Visibility #

Read Visibility Source # 
Show Visibility Source # 

data Prog Source #

A FlatCurry module.

A value of this data type has the form

Prog modname imports typedecls functions opdecls

where

modname
Name of this module
imports
List of modules names that are imported
typedecls
Type declarations
funcdecls
Function declarations
opdecls
Operator declarations

Constructors

Prog String [String] [TypeDecl] [FuncDecl] [OpDecl] 

Instances

Eq Prog Source # 

Methods

(==) :: Prog -> Prog -> Bool #

(/=) :: Prog -> Prog -> Bool #

Data Prog Source # 

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Prog -> c Prog #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Prog #

toConstr :: Prog -> Constr #

dataTypeOf :: Prog -> DataType #

dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c Prog) #

dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Prog) #

gmapT :: (forall b. Data b => b -> b) -> Prog -> Prog #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Prog -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Prog -> r #

gmapQ :: (forall d. Data d => d -> u) -> Prog -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Prog -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Prog -> m Prog #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Prog -> m Prog #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Prog -> m Prog #

Read Prog Source # 
Show Prog Source # 

Methods

showsPrec :: Int -> Prog -> ShowS #

show :: Prog -> String #

showList :: [Prog] -> ShowS #

data TypeDecl Source #

Declaration of algebraic data type or type synonym.

A data type declaration of the form

data t x1...xn = ...| c t1....tkc |...

is represented by the FlatCurry term

Type t [i1,...,in] [...(Cons c kc [t1,...,tkc])...]

where each ij is the index of the type variable xj

Note: The type variable indices are unique inside each type declaration and are usually numbered from 0.

Thus, a data type declaration consists of the name of the data type, a list of type parameters and a list of constructor declarations.

Instances

Eq TypeDecl Source # 
Data TypeDecl Source # 

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> TypeDecl -> c TypeDecl #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c TypeDecl #

toConstr :: TypeDecl -> Constr #

dataTypeOf :: TypeDecl -> DataType #

dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c TypeDecl) #

dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c TypeDecl) #

gmapT :: (forall b. Data b => b -> b) -> TypeDecl -> TypeDecl #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> TypeDecl -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> TypeDecl -> r #

gmapQ :: (forall d. Data d => d -> u) -> TypeDecl -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> TypeDecl -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> TypeDecl -> m TypeDecl #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> TypeDecl -> m TypeDecl #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> TypeDecl -> m TypeDecl #

Read TypeDecl Source # 
Show TypeDecl Source # 

data TypeExpr Source #

Type expressions.

A type expression is either a type variable, a function type, or a type constructor application.

Note: the names of the predefined type constructors are Int, Float, Bool, Char, IO, Success, () (unit type), (,...,) (tuple types), [] (list type)

Constructors

TVar !TVarIndex

type variable

FuncType TypeExpr TypeExpr

function type t1 -> t2

TCons QName [TypeExpr]

type constructor application

Instances

Eq TypeExpr Source # 
Data TypeExpr Source # 

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> TypeExpr -> c TypeExpr #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c TypeExpr #

toConstr :: TypeExpr -> Constr #

dataTypeOf :: TypeExpr -> DataType #

dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c TypeExpr) #

dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c TypeExpr) #

gmapT :: (forall b. Data b => b -> b) -> TypeExpr -> TypeExpr #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> TypeExpr -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> TypeExpr -> r #

gmapQ :: (forall d. Data d => d -> u) -> TypeExpr -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> TypeExpr -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> TypeExpr -> m TypeExpr #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> TypeExpr -> m TypeExpr #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> TypeExpr -> m TypeExpr #

Read TypeExpr Source # 
Show TypeExpr Source # 

type TVarIndex = Int Source #

Type variables are represented by (TVar i) where i is a type variable index.

data ConsDecl Source #

A constructor declaration consists of the name and arity of the constructor and a list of the argument types of the constructor.

Constructors

Cons QName Int Visibility [TypeExpr] 

Instances

Eq ConsDecl Source # 
Data ConsDecl Source # 

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> ConsDecl -> c ConsDecl #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c ConsDecl #

toConstr :: ConsDecl -> Constr #

dataTypeOf :: ConsDecl -> DataType #

dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c ConsDecl) #

dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c ConsDecl) #

gmapT :: (forall b. Data b => b -> b) -> ConsDecl -> ConsDecl #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> ConsDecl -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> ConsDecl -> r #

gmapQ :: (forall d. Data d => d -> u) -> ConsDecl -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> ConsDecl -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> ConsDecl -> m ConsDecl #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> ConsDecl -> m ConsDecl #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> ConsDecl -> m ConsDecl #

Read ConsDecl Source # 
Show ConsDecl Source # 

data OpDecl Source #

Operator declarations.

An operator declaration fix p n in Curry corresponds to the FlatCurry term (Op n fix p).

Note: the constructor definition of Op differs from the original PAKCS definition using Haskell type Integer instead of Int for representing the precedence.

Constructors

Op QName Fixity Integer 

Instances

Eq OpDecl Source # 

Methods

(==) :: OpDecl -> OpDecl -> Bool #

(/=) :: OpDecl -> OpDecl -> Bool #

Data OpDecl Source # 

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> OpDecl -> c OpDecl #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c OpDecl #

toConstr :: OpDecl -> Constr #

dataTypeOf :: OpDecl -> DataType #

dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c OpDecl) #

dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c OpDecl) #

gmapT :: (forall b. Data b => b -> b) -> OpDecl -> OpDecl #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> OpDecl -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> OpDecl -> r #

gmapQ :: (forall d. Data d => d -> u) -> OpDecl -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> OpDecl -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> OpDecl -> m OpDecl #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> OpDecl -> m OpDecl #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> OpDecl -> m OpDecl #

Read OpDecl Source # 
Show OpDecl Source # 

data Fixity Source #

Fixity of an operator.

Constructors

InfixOp

non-associative infix operator

InfixlOp

left-associative infix operator

InfixrOp

right-associative infix operator

Instances

Eq Fixity Source # 

Methods

(==) :: Fixity -> Fixity -> Bool #

(/=) :: Fixity -> Fixity -> Bool #

Data Fixity Source # 

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Fixity -> c Fixity #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Fixity #

toConstr :: Fixity -> Constr #

dataTypeOf :: Fixity -> DataType #

dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c Fixity) #

dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Fixity) #

gmapT :: (forall b. Data b => b -> b) -> Fixity -> Fixity #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Fixity -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Fixity -> r #

gmapQ :: (forall d. Data d => d -> u) -> Fixity -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Fixity -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Fixity -> m Fixity #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Fixity -> m Fixity #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Fixity -> m Fixity #

Read Fixity Source # 
Show Fixity Source # 

data FuncDecl Source #

Data type for representing function declarations.

A function declaration in FlatCurry is a term of the form

(Func name arity type (Rule [i_1,...,i_arity] e))

and represents the function "name" with definition

name :: type
name x_1...x_arity = e

where each i_j is the index of the variable x_j

Note: The variable indices are unique inside each function declaration and are usually numbered from 0.

External functions are represented as

Func name arity type (External s)

where s is the external name associated to this function.

Thus, a function declaration consists of the name, arity, type, and rule.

Instances

Eq FuncDecl Source # 
Data FuncDecl Source # 

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> FuncDecl -> c FuncDecl #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c FuncDecl #

toConstr :: FuncDecl -> Constr #

dataTypeOf :: FuncDecl -> DataType #

dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c FuncDecl) #

dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c FuncDecl) #

gmapT :: (forall b. Data b => b -> b) -> FuncDecl -> FuncDecl #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> FuncDecl -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> FuncDecl -> r #

gmapQ :: (forall d. Data d => d -> u) -> FuncDecl -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> FuncDecl -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> FuncDecl -> m FuncDecl #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> FuncDecl -> m FuncDecl #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> FuncDecl -> m FuncDecl #

Read FuncDecl Source # 
Show FuncDecl Source # 

data Rule Source #

A rule is either a list of formal parameters together with an expression or an External tag.

Constructors

Rule [VarIndex] Expr 
External String 

Instances

Eq Rule Source # 

Methods

(==) :: Rule -> Rule -> Bool #

(/=) :: Rule -> Rule -> Bool #

Data Rule Source # 

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Rule -> c Rule #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Rule #

toConstr :: Rule -> Constr #

dataTypeOf :: Rule -> DataType #

dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c Rule) #

dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Rule) #

gmapT :: (forall b. Data b => b -> b) -> Rule -> Rule #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Rule -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Rule -> r #

gmapQ :: (forall d. Data d => d -> u) -> Rule -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Rule -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Rule -> m Rule #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Rule -> m Rule #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Rule -> m Rule #

Read Rule Source # 
Show Rule Source # 

Methods

showsPrec :: Int -> Rule -> ShowS #

show :: Rule -> String #

showList :: [Rule] -> ShowS #

data Expr Source #

Data type for representing expressions.

Remarks:

  1. if-then-else expressions are represented as function calls:
(if e1 then e2 else e3)

is represented as

(Comb FuncCall (Prelude,"if_then_else") [e1,e2,e3])
  1. Higher order applications are represented as calls to the (external) function apply. For instance, the rule
app f x = f x

is represented as

(Rule  [0,1] (Comb FuncCall (Prelude,"apply") [Var 0, Var 1]))
  1. A conditional rule is represented as a call to an external function cond where the first argument is the condition (a constraint).

For instance, the rule

equal2 x | x=:=2 = success

is represented as

  (Rule [0]
      (Comb FuncCall (Prelude,"cond")
            [Comb FuncCall (Prelude,"=:=") [Var 0, Lit (Intc 2)],
            Comb FuncCall (Prelude,"success") []]))
  
  1. Functions with evaluation annotation choice are represented by a rule whose right-hand side is enclosed in a call to the external function Prelude.commit. Furthermore, all rules of the original definition must be represented by conditional expressions (i.e., (cond [c,e])) after pattern matching.

Example:

  m eval choice
  m [] y = y
  m x [] = x
  

is translated into (note that the conditional branches can be also wrapped with Free declarations in general):

  Rule [0,1]
    (Comb FuncCall (Prelude,"commit")
      [Or (Case Rigid (Var 0)
            [(Pattern (Prelude,"[]") []
                (Comb FuncCall (Prelude,"cond")
                      [Comb FuncCall (Prelude,"success") [],
                        Var 1]))] )
          (Case Rigid (Var 1)
            [(Pattern (Prelude,"[]") []
                (Comb FuncCall (Prelude,"cond")
                      [Comb FuncCall (Prelude,"success") [],
                        Var 0]))] )])
  

Operational meaning of (Prelude.commit e): evaluate e with local search spaces and commit to the first (Comb FuncCall (Prelude,"cond") [c,ge]) in e whose constraint c is satisfied

Constructors

Var VarIndex

Variable, represented by unique index

Lit Literal

Literal (IntegerFloatChar constant)

Comb CombType QName [Expr]

Application (f e1 ... en) of function/constructor f with n <= arity f

Free [VarIndex] Expr

Introduction of free local variables for an expression

Let [(VarIndex, Expr)] Expr

Local let-declarations

Or Expr Expr

Disjunction of two expressions (resulting from overlapping left-hand sides)

Case SrcRef CaseType Expr [BranchExpr]

case expression

Typed Expr TypeExpr

typed expression

Instances

Eq Expr Source # 

Methods

(==) :: Expr -> Expr -> Bool #

(/=) :: Expr -> Expr -> Bool #

Data Expr Source # 

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Expr -> c Expr #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Expr #

toConstr :: Expr -> Constr #

dataTypeOf :: Expr -> DataType #

dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c Expr) #

dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Expr) #

gmapT :: (forall b. Data b => b -> b) -> Expr -> Expr #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Expr -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Expr -> r #

gmapQ :: (forall d. Data d => d -> u) -> Expr -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Expr -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Expr -> m Expr #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Expr -> m Expr #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Expr -> m Expr #

Read Expr Source # 
Show Expr Source # 

Methods

showsPrec :: Int -> Expr -> ShowS #

show :: Expr -> String #

showList :: [Expr] -> ShowS #

data Literal Source #

Data type for representing literals.

A literal is either an integer, a float, or a character constant.

Note: The constructor definition of Intc differs from the original PAKCS definition. It uses Haskell type Integer instead of Int to provide an unlimited range of integer numbers. Furthermore, float values are represented with Haskell type Double instead of Float.

Instances

Eq Literal Source # 

Methods

(==) :: Literal -> Literal -> Bool #

(/=) :: Literal -> Literal -> Bool #

Data Literal Source # 

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Literal -> c Literal #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Literal #

toConstr :: Literal -> Constr #

dataTypeOf :: Literal -> DataType #

dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c Literal) #

dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Literal) #

gmapT :: (forall b. Data b => b -> b) -> Literal -> Literal #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Literal -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Literal -> r #

gmapQ :: (forall d. Data d => d -> u) -> Literal -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Literal -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Literal -> m Literal #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Literal -> m Literal #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Literal -> m Literal #

Read Literal Source # 
Show Literal Source # 

data CombType Source #

Data type for classifying combinations (i.e., a function/constructor applied to some arguments).

Constructors

FuncCall

a call to a function where all arguments are provided

ConsCall

a call with a constructor at the top, all arguments are provided

FuncPartCall Int

a partial call to a function (i.e., not all arguments are provided) where the parameter is the number of missing arguments

ConsPartCall Int

a partial call to a constructor along with number of missing arguments

Instances

Eq CombType Source # 
Data CombType Source # 

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> CombType -> c CombType #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c CombType #

toConstr :: CombType -> Constr #

dataTypeOf :: CombType -> DataType #

dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c CombType) #

dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c CombType) #

gmapT :: (forall b. Data b => b -> b) -> CombType -> CombType #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> CombType -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> CombType -> r #

gmapQ :: (forall d. Data d => d -> u) -> CombType -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> CombType -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> CombType -> m CombType #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> CombType -> m CombType #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> CombType -> m CombType #

Read CombType Source # 
Show CombType Source # 

data CaseType Source #

Classification of case expressions, either flexible or rigid.

Constructors

Rigid

rigid case expression

Flex

flexible case expression

Instances

Eq CaseType Source # 
Data CaseType Source # 

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> CaseType -> c CaseType #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c CaseType #

toConstr :: CaseType -> Constr #

dataTypeOf :: CaseType -> DataType #

dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c CaseType) #

dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c CaseType) #

gmapT :: (forall b. Data b => b -> b) -> CaseType -> CaseType #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> CaseType -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> CaseType -> r #

gmapQ :: (forall d. Data d => d -> u) -> CaseType -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> CaseType -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> CaseType -> m CaseType #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> CaseType -> m CaseType #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> CaseType -> m CaseType #

Read CaseType Source # 
Show CaseType Source # 

data BranchExpr Source #

Branches in a case expression.

Branches (m.c x1...xn) -> e in case expressions are represented as

(Branch (Pattern (m,c) [i1,...,in]) e)

where each ij is the index of the pattern variable xj, or as

(Branch (LPattern (Intc i)) e)

for integers as branch patterns (similarly for other literals like float or character constants).

Constructors

Branch Pattern Expr 

Instances

Eq BranchExpr Source # 
Data BranchExpr Source # 

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> BranchExpr -> c BranchExpr #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c BranchExpr #

toConstr :: BranchExpr -> Constr #

dataTypeOf :: BranchExpr -> DataType #

dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c BranchExpr) #

dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c BranchExpr) #

gmapT :: (forall b. Data b => b -> b) -> BranchExpr -> BranchExpr #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> BranchExpr -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> BranchExpr -> r #

gmapQ :: (forall d. Data d => d -> u) -> BranchExpr -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> BranchExpr -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> BranchExpr -> m BranchExpr #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> BranchExpr -> m BranchExpr #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> BranchExpr -> m BranchExpr #

Read BranchExpr Source # 
Show BranchExpr Source # 

data Pattern Source #

Patterns in case expressions.

Constructors

Pattern QName [VarIndex]

constructor pattern

LPattern Literal

literal pattern

Instances

Eq Pattern Source # 

Methods

(==) :: Pattern -> Pattern -> Bool #

(/=) :: Pattern -> Pattern -> Bool #

Data Pattern Source # 

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Pattern -> c Pattern #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Pattern #

toConstr :: Pattern -> Constr #

dataTypeOf :: Pattern -> DataType #

dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c Pattern) #

dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Pattern) #

gmapT :: (forall b. Data b => b -> b) -> Pattern -> Pattern #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Pattern -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Pattern -> r #

gmapQ :: (forall d. Data d => d -> u) -> Pattern -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Pattern -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Pattern -> m Pattern #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Pattern -> m Pattern #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Pattern -> m Pattern #

Read Pattern Source # 
Show Pattern Source # 

Functions for reading and writing FlatCurry terms

readFlatCurry :: FilePath -> IO (Maybe Prog) Source #

Reads an FlatCurry file (extension ".fcy") and eventually returns the corresponding FlatCurry program term (type Prog).

readFlatInterface :: String -> IO (Maybe Prog) Source #

Reads a FlatInterface file (extension ".fint") and returns the corresponding term (type Prog) as a value of type Maybe.

readExtFlatCurry :: FilePath -> IO (Maybe Prog) Source #

Reads an Extended FlatCurry file (extension ".efc") and eventually returns the corresponding FlatCurry program term (type Prog).

readFlat :: FilePath -> IO (Maybe Prog) Source #

Reads a Flat file and returns the corresponding term (type Prog) as a value of type Maybe.

writeFlatCurry :: String -> Prog -> IO () Source #

Writes a FlatCurry program term into a file.

writeExtendedFlat :: String -> Prog -> IO () Source #

Writes a FlatCurry program term with source references into a file.