xotl.fl
- Language API and AST¶
-
xotl.fl.
parse
(program_source: str, *, debug: bool = False)[source]¶ Parse the program source and return its AST.
It returns a list of definitions. Definitions come in five types:
- Type annotations, which are dictionaries of type
TypeEnvironment
; - Value definitions, which may span several
equations
; - Data type definitions,
DataType
; - Type classes,
TypeClass
; and - Instances,
Instance
.
This function doesn’t type-check the program.
Example:
>>> parse(""" ... data List a = Nil | Cons a (List a) ... lhead :: List a -> a ... lhead (Cons a _) = a ... """) [<Data List a = <DataCons Nil> | <DataCons Cons a (List a)>>, {'lhead': <TypeScheme: forall a. (List a) -> a>}, <equation lhead (Cons a _) = Identifier('a')>]
- Type annotations, which are dictionaries of type