Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to idris 1.2.0 and malfunction v0.2.1 #7

Open
wants to merge 53 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
cdb44f6
Add .gitignore
May 11, 2018
999bdbb
Update to idris 1.2.0 and malfunction v0.2.1
May 16, 2018
383fe6f
Update README.md
ioanluca May 16, 2018
a057389
Printout of the Lang representation
May 17, 2018
233b7aa
Remove binaries
May 17, 2018
64a6e84
Update README.md
May 17, 2018
1daff8c
Generate formatted .mlf files
May 17, 2018
44f368b
Remove quotes completely
May 17, 2018
15b2ab6
SimpleDecls for now
May 17, 2018
39ebb31
Update .gitignore
May 18, 2018
a949a6d
Lifted decls
May 18, 2018
ce3375d
Add explicit types
May 18, 2018
33ada00
Use IRcase instead
May 18, 2018
7446772
Add code generation for LLazyApp, LLazyExp, LLam and LForce
May 21, 2018
385219c
Fix unreachable pattern match
May 21, 2018
40575df
Moved some stuff around
May 22, 2018
9ffae0a
Update .gitignore
May 22, 2018
20518f7
Generate .lang file, use names for lambda args
May 22, 2018
532d549
Add explicit types
May 22, 2018
e7e1ee4
Add support for stack lts 10.10
May 23, 2018
393d1d9
Add a smaller test case
May 23, 2018
4baa7c7
Add map from CoNames to ConTags
May 24, 2018
2b2c5f6
Remove unnecessary let statement in pattern matching
May 25, 2018
1ceeadf
Remove double tags
May 25, 2018
5d31901
Remove unused imports
May 29, 2018
9015bf3
Bump to idris-1.3.0
May 29, 2018
666e43e
Add tests
May 31, 2018
bab8bc5
Use the --interface flag to trigger the eval
May 31, 2018
e161011
Print every LExp
May 31, 2018
b8395a9
Fix function being applied to one argument
Jun 1, 2018
7e557b1
More informative arguments
Jun 1, 2018
364ac41
Use integers for constructors that have no fields
Jun 1, 2018
818122a
Lazy Apps
Jun 6, 2018
2eecbcc
Remove take.txt
Jun 6, 2018
39cc519
Translate monad
Jun 7, 2018
b3f12ae
Refactor
Jun 7, 2018
fbc8c80
Refactor
Jun 7, 2018
7c2331a
Refactor
Jun 7, 2018
62c4787
Add Big Integer to Sexp
Jun 7, 2018
ab5d337
Add build and debug tasks
Jun 7, 2018
06cee21
Add type signatuer for showUsage
Jun 8, 2018
7d32030
Refactor
Jun 8, 2018
b8ae55d
Add vscode tasks
Jun 8, 2018
1857b97
Simplify some defs
Jun 13, 2018
c532856
Update tasks.json
Jun 15, 2018
2c5a684
Fix world type
Jun 15, 2018
4f0b0aa
Refactor
Jun 15, 2018
c753e9b
Laziness
Jun 15, 2018
9174c38
Provide World Arg in the body of runMain
Jun 18, 2018
5bdf88a
Laziness
Jun 18, 2018
66029bb
Fix BigInt pattern matching
Jun 19, 2018
697d9ea
Pattern ordering test
Jun 19, 2018
1d7eeeb
Benchmark and some more tests
Jun 20, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# haskell
dist
dist-*
cabal-dev
*.o
*.out
*.hi
*.chi
*.chs.h
*.dyn_o
*.dyn_hi
.hpc
.hsenv
.cabal-sandbox/
cabal.sandbox.config
*.prof
*.aux
*.hp
*.eventlog
.stack-work/
cabal.project.local
cabal.project.local~
.HTF/
.ghc.environment.*

# idris
*.ibc
*.lang

# malfunction
*.mlf

# general
*.log
26 changes: 26 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "ghc",
"name": "haskell-debug-adapter",
"request": "launch",
"internalConsoleOptions": "openOnSessionStart",
"workspace": "${workspaceRoot}",
"startup": "${workspaceRoot}/src/Main.hs",
"startupFunc": "",
"startupArgs": "",
"stopOnEntry": true,
"mainArgs": "",
"ghciPrompt": "H>>= ",
"ghciInitialPrompt": "Prelude>",
"ghciCmd": "stack ghci --test --no-load --no-build --main-is TARGET --ghci-options -fprint-evld-with-show",
"ghciEnv": {},
"logFile": "${workspaceRoot}/.vscode/phoityne.log",
"logLevel": "WARNING"
}
]
}
68 changes: 68 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "stack install",
"type": "shell",
"command": "stack install",
"group": {
"kind": "build",
"isDefault": true
},
"presentation": {
"echo": true,
"reveal": "always",
"focus": true,
}
},
{
"label": "idrmlf compile",
"type": "shell",
"command": "idris ${relativeFile} --codegen malfunction -o test/${fileBasenameNoExtension}.o && test/${fileBasenameNoExtension}.o",
"presentation": {
"echo": true,
"reveal": "always",
"focus": true,
}
},{
"label": "idrmlf eval",
"type": "shell",
"command": "idris ${relativeFile} --codegen malfunction --interface -o test/${fileBasenameNoExtension}",
"presentation": {
"echo": true,
"reveal": "always",
"focus": true,
}
},
{
"label": "idrmlf run",
"type": "shell",
"command": "test/${fileBasenameNoExtension}.o",
"presentation": {
"echo": true,
"reveal": "always",
"focus": true,
}
},
{
"label": "malfunction compile",
"type": "shell",
"command": "malfunction compile ${relativeFile} -o test/${fileBasenameNoExtension}_1.o && test/${fileBasenameNoExtension}_1.o",
"presentation": {
"echo": true,
"reveal": "always",
"focus": true,
}
},
{
"label": "clean test",
"type": "shell",
"command": "rm test/*.ibc test/*.o test/*.lang test/*.mlf",
"presentation": {
"reveal": "never",
},
}
]
}
25 changes: 17 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,28 @@
# Idris backend for Malfunction

Compiles Idris to [Malfunction](https://github.com/stedolan/malfunction)
Compiles Idris to [Malfunction](https://github.com/stedolan/malfunction).

It seems to go pretty fast:

$ idris pythag.idr -o pythag-idris
$ idris pythag.idr --codegen malfunction -o pythag-malfunction

$ time ./pythag-idris > /dev/null

real 0m4.548s
user 0m4.528s
sys 0m0.016s

real 0m13.102s
user 0m13.084s
sys 0m0.004s
$ time ./pythag-malfunction > /dev/null

real 0m1.096s
user 0m1.092s
real 0m0.654s
user 0m0.652s
sys 0m0.000s
$

Tested on:
* Ubuntu `16.04.4 LTS 64-bit`
* Intel® Core™ i5-2500 CPU @ 3.30GHz × 4
* 8 GB RAM
* Idris `1.2.0`
* Malfunction `v0.2.1`
* OCaml `4.05.0+flambda`
74 changes: 74 additions & 0 deletions benchmark/BinaryTrees.idr
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
--
-- The Computer Language Benchmarks Game
-- https://salsa.debian.org/benchmarksgame-team/benchmarksgame/
--
-- Contributed by Don Stewart
-- *reset*
--
-- import System.Environment
import Data.Bits
-- import Text.Printf

--
-- an artificially strict tree.
--
-- normally you would ensure the branches are lazy, but this benchmark
-- requires strict allocation.
--
data Tree = Nil | Node Int Tree Tree

minN : Int
minN = 4

-- io s n t = printf "%s of depth %d\t check: %d\n" s n t
-- io : String -> Int -> Int -> IO ()
-- io s n t = putStrLn (s ++ " of depth " ++ (show d) ++ "\t check: " ++ (show t))

-- traverse the tree, counting up the nodes
ccheck : Tree -> Int
ccheck Nil = 0
ccheck (Node i l r) = 1 + ccheck l + ccheck r

-- build a tree
make : Int -> Int -> Tree
make i 0 = Node i Nil Nil
make i d = Node i (make d d2) (make d2 d2)
where d2 = d-1

-- allocate and check lots of trees
sumT : Int -> Int -> Int -> Int
sumT d 0 t = t
sumT d i t = sumT d (i-1) (t + a)
where a = ccheck (make 0 d)

-- generate many trees
depth : Int -> Int -> List (Int, Int, Int)
depth d m =
if d <= m then (n, d, (sumT d n 0)) :: depth (d+2) m
else []
where n = 2 * (m - d + minN)


main : IO ()
main = do
-- n <- getArgs >>= readIO . head
let n = 25
let maxN = max (minN + 2) n
let stretchN = maxN + 1

-- stretch memory tree
let c = ccheck (make 0 stretchN)
-- io "stretch tree" stretchN c

-- allocate a long lived tree
let long = make 0 maxN

-- allocate, walk, and deallocate many bottom-up binary trees
let vs = depth minN maxN
-- traverse (\ (m,d,i) => io (show m ++ "\t trees") d i) vs
traverse_ (putStrLn . show) vs

-- confirm the the long-lived binary tree still exists
-- io "long lived tree" maxN (ccheck long)


7 changes: 7 additions & 0 deletions benchmark/Fib.idr
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
myfib : Integer -> Integer
myfib 0 = 1
myfib 1 = 1
myfib n = myfib (n - 1) + myfib (n - 2)

main : IO ()
main = putStrLn $ show $ myfib 40
22 changes: 22 additions & 0 deletions docs/notes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Notes on what I've been doing

## Idris and TDD with dep types

## OCaml runtime

## Malfunction

### Why lang?

## Compilers

## VSCode + other dev tools

## Haskell

## IRC

## Extras (Academia, SPLS, other talks)

## Future work
### FFI
9 changes: 2 additions & 7 deletions idris-malfunction.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,21 @@

name: idris-malfunction
version: 0.1.0.0
-- synopsis:
-- description:
license: MIT
license-file: LICENSE
author: Stephen Dolan
maintainer: [email protected]
-- copyright:
-- category:
build-type: Simple
-- extra-source-files:
cabal-version: >=1.10

executable idris-codegen-malfunction
main-is: Main.hs
-- other-modules:
-- other-extensions:
other-modules: IRTS.CodegenMalfunction
build-depends: base
hs-source-dirs: src
default-language: Haskell2010
build-depends: containers
build-depends: idris
build-depends: process
build-depends: directory
build-depends: filepath
Loading