Quickstart
After Installation, spend five minutes with lessons 01 and 02.
Clone the repository to get
examples/.With pip, use the Python that holds
curry. From a checkout, runmake stageand putinstall/binonPATH.Start Python in
examples/for the transcripts below.
With pip, run python go.py in each lesson’s directory. ./run uses
a staged checkout. Continue with Using the API for the
rest of the tour; Examples is the catalog.
1. Hello, both ways
The first lesson’s small module accepts a Python value and returns one:
>>> import curry
>>> curry.path.insert(0, '01-run-with-python')
>>> from curry.lib import Hello as H
>>> curry.eval(H.greet('Python')).one()
'Hello, Python!'
Run ./run in examples/01-run-with-python for the complete
lesson, including several answers and three corrected
mistakes. The guide explains Consume results and
Values and types when you are ready for them.
2. Compile and parse
The second lesson builds a small module from source text, then builds a text goal with that module in scope:
>>> Nat = curry.compile('''
... data Nat = O | I Nat deriving Show
... natToInt :: Nat -> Int
... natToInt O = 0
... natToInt (I n) = 1 + natToInt n
... ''')
>>> goal = Nat.natToInt(Nat.I(Nat.O))
>>> curry.eval(goal).one()
1
>>> goal = curry.parse('natToInt (I (I O))', imports=[Nat])
>>> curry.eval(goal).one()
2
Run ./run in examples/02-dynamic-code-generation for the complete
lesson. Continue with the guide’s
tree values, logic and
encapsulated search. For command-line execution,
start with 00; for an interactive session, see
The REPL.
See Curry packages to use packages from the Curry Package Manager.