Skip to content

cutsea110/ifl

Repository files navigation

Implementing Functional Languages

Haskell Docker Cloud Build Status

Reference: Simon L. Payton Jones, David R. Lester Implementing Functional Languages: a tutorial, 1991

How to use

Run on local

$ cabal run ifl -- -V
    ____________
   /  _/ ____/ /
   / // /_  / /
 _/ // __/ / /___
/___/_/   /_____/ Implimenting Functional Languages

> cabal run ifl -- [OPTION...] <program-file>
OPTION
  -c Compiler   --compiler=Compiler      compiler name (mark1 | mark2 | mark3 | mark4 | mark5 | mark5alt | mark5gc | mark5revgc | mark5cp | gmark1 | gmark2 | gmark3 | gmark4 | gmark5 | gmark6 | gmark7 | timark1 | timark1cp | timark2 | timark3 | timark4 | timark5 | timark6)
  -v            --verbose                step output on stderr
  -t Threshold  --threshold=Threshold    threshold for Garbage Collection
  -l            --convert-to-list-based  convert to list based program
  -p            --profile                profile output
  -V, -?        --version                show version

Run on docker

See Dockerhub cutsea110/ifl.

$ cat test.ifl
fib n = if (n<2) 1 (fib (n-1) + fib (n-2));
main = fib 10

$ docker run -v ./:/work -it --rm cutsea110/ifl:0.3.18 ifl -c gmark7 /work/test.ifl
89

Tips

How to confirm compiled code of any program for debug on Gmachine.Mark7.

ghci> let p = "s f g x = f x (g x)"
ghci> compileSc [] . head . parse $ p

When you take recursive function, you have to give an environment like below:

ghci> let p = "fib n = if (n<2) 1 (fib (n-1) + fib (n-2))"
ghci> compileSc [("fib", Label "fib")] . head . parse $ p

For Developer

How to build Docker image

You should specify the version 0.3.19, because the latest version is 0.3.18.

$ docker buildx build --load -t cutsea110/ifl:0.3.19 .

How to run on Docker image

I suppose that you have some test programs for ifl in ${PWD}/examples directory.

$ docker run -v ${PWD}/examples:/work -it --rm cutsea110/ifl:0.3.19 ifl -v -c pgmark1 /work/testProg80.ifl

or try this.

$ docker run -v ${PWD}/examples:/work -it --rm cutsea110/ifl:0.3.19 ifl -t 1000 -l -v -c timark6 /work/testProg134.ifl

Further more, just only on the TMark6, You can use -p option which profile your code.

$ docker run -v ${PWD}/examples:/work -it --rm cutsea110/ifl:0.3.19 ifl -t 1000 -l -v -c timark6 -p /work/testProg134.ifl

Share Dockerhub

$ docker login
$ docker push cutsea110/ifl:0.3.19

Update This README

You should update docker image version for next.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published