diff --git a/examples/lambda_calculus.mil b/examples/lambda_calculus.mil new file mode 100644 index 0000000..c9501de --- /dev/null +++ b/examples/lambda_calculus.mil @@ -0,0 +1,46 @@ +# Helpers +datatype 'a list { + Cons ('a, 'a list), + Empty, +} + +datatype 'a maybe { + Just 'a, + Nothing, +} + +# Lambda calculus term, nameless representation +datatype term { + Var int + Int int + Abs term + App (term, term) +} + +# Result of the evaluation +datatype value { + Int int + Closure (env, term) +} + +alias env = value list + +typecheck add_binding : value -> env -> env +def add_binding v env = Cons v env + +typecheck lookup : int -> env -> value maybe +def lookup _ = Nothing + | lookup 0 = Just x + | lookup n = lookup (subtract n 1) xs + +typecheck eval : env -> term -> value +def eval e = match lookup idx e { + case -> v + case -> abort "Variable out of scope" + } + + | eval e = Int x + | eval e = Closure e t + | eval e = + let def new_env = add_binding (eval e t2) e + in eval new_env t1 diff --git a/extra/milly.kak b/extra/milly.kak new file mode 100644 index 0000000..86905ea --- /dev/null +++ b/extra/milly.kak @@ -0,0 +1,49 @@ +# Detection +hook global BufCreate .*\.(mil) %{ + set-option buffer filetype milly +} + +hook global WinSetOption filetype=milly %{ + require-module milly + +} + +hook -group milly-highlighter global WinSetOption filetype=milly %{ + add-highlighter window/milly ref milly + hook -once -always window WinSetOption filetype=.* %{ + remove-highlighter window/milly + } +} + +provide-module milly %§ + +# Highlighters & Completion + +add-highlighter shared/milly regions +add-highlighter shared/milly/code default-region group +add-highlighter shared/milly/comment region (^|\h)\K# $ fill comment +add-highlighter shared/milly/double_string region -recurse %{(?