Skip to content

cutsea110/ifl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1,246 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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 | pgmark1 | pgmark2 | pgmark3 | pgmark4)
  -l Lifter       --lifter=Lifter          lambda lifter name (lmark1 | lmark2 | lmark3)
  -v              --verbose                step output on stderr
  -w              --pretty verbose         step output with showing heap on stderr
  -t Threshold    --threshold=Threshold    threshold for Garbage Collection
  -m MachineSize  --machines=MachineSize   Machine size for Parallel G-machine (default: 4)
  -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.31 -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

docker login## For Developer

How to build Docker image

You should specify the version 0.3.32, because the latest version is 0.3.31.

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

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.32 -v -c pgmark4 /work/testProg160.ifl

or try this.

$ docker run -v ${PWD}/examples:/work -it --rm cutsea110/ifl:0.3.32 -t 1000 -L -v -c timark6 /work/testProg159.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.32 -t 1000 -L -v -c timark6 -p /work/testProg159.ifl

If you want to try the latest PgMark2, you can use -w option which pretty verbose. This option show heap data for all steps, so you know this option make the program slow.

$ docker run -v ${PWD}/examples:/work -it --rm cutsea110/ifl:0.3.32 -w -c pgmark4 /work/testProg160.ifl

Share Dockerhub

$ docker login
$ docker push cutsea110/ifl:0.3.32

Update This README

You should update docker image version for next.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors