idris-1.3.4: Functional Programming Language with Dependent Types

License | BSD3
Maintainer | The Idris Community.
Safe Haskell | None
Language | Haskell2010

Idris.PartialEval

Description

Synopsis

- partial_eval :: Context -> [(Name, Maybe Int)] -> [Either Term (Term, Term)] -> Maybe [Either Term (Term, Term)]
- getSpecApps :: IState -> [Name] -> Term -> [(Name, [(PEArgType, Term)])]
- specType :: [(PEArgType, Term)] -> Type -> (Type, [(PEArgType, Term)])
- mkPE_TyDecl :: IState -> [(PEArgType, Term)] -> Type -> PTerm
- mkPE_TermDecl :: IState -> Name -> Name -> PTerm -> [(PEArgType, Term)] -> PEDecl
- data PEArgType
  - = ImplicitS Name
  - | ImplicitD Name
  - | ConstraintS
  - | ConstraintD
  - | ExplicitS
  - | ExplicitD
  - | UnifiedD
- pe_app :: PEDecl -> PTerm
- pe_def :: PEDecl -> PTerm
- pe_clauses :: PEDecl -> [(PTerm, PTerm)]
- pe_simple :: PEDecl -> Bool

# Documentation

partial_eval :: Context -> [(Name, Maybe Int)] -> [Either Term (Term, Term)] -> Maybe [Either Term (Term, Term)] #

Partially evaluates given terms under the given context. It is an error if partial evaluation fails to make any progress. Making progress is defined as: all of the names given with explicit reduction limits (in practice, the function being specialised) must have reduced at least once. If we don't do this, we might end up making an infinite function after applying the transformation.

getSpecApps :: IState -> [Name] -> Term -> [(Name, [(PEArgType, Term)])] #

Get specialised applications for a given function

specType :: [(PEArgType, Term)] -> Type -> (Type, [(PEArgType, Term)]) #

Specialises the type of a partially evaluated TT function returning a pair of the specialised type and the types of expected arguments.

mkPE_TyDecl :: IState -> [(PEArgType, Term)] -> Type -> PTerm #

Creates an Idris type declaration given current state and a specialised TT function application type. Can be used in combination with the output of `specType`.

This should: specialise any static argument position, then generalise over any function applications in the result.

mkPE_TermDecl #

Arguments

:: IState |
-> Name |
-> Name |
-> PTerm | Type of specialised function
-> [(PEArgType, Term)] |
-> PEDecl |

Creates a new declaration for a specialised function application. Simple version at the moment: just create a version which is a direct application of the function to be specialised. More complex version to do: specialise the definition clause by clause

data PEArgType #

Data type representing binding-time annotations for partial evaluation of arguments

Constructors

ImplicitS Name | Implicit static argument
ImplicitD Name | Implicit dynamic argument
ConstraintS | Implementation constraint
ConstraintD | Implementation constraint
ExplicitS | Explicit static argument
ExplicitD | Explicit dynamic argument
UnifiedD | Erasable dynamic argument (found under unification)

#### Instances

Instances details

Show PEArgType # |
Instance details Defined in Idris.PartialEval Methods showsPrec :: Int -> PEArgType -> ShowS # show :: PEArgType -> String # showList :: [PEArgType] -> ShowS #
Eq PEArgType # |
Instance details Defined in Idris.PartialEval Methods (==) :: PEArgType -> PEArgType -> Bool # (/=) :: PEArgType -> PEArgType -> Bool #

pe_app :: PEDecl -> PTerm #

pe_def :: PEDecl -> PTerm #

pe_clauses :: PEDecl -> [(PTerm, PTerm)] #

pe_simple :: PEDecl -> Bool #