Difference between revisions of "Stdlib"
m |
m |
||
Line 78: | Line 78: | ||
infixl ++ 4 |
infixl ++ 4 |
||
infix !% 5 |
infix !% 5 |
||
+ | |||
+ | sleep = Prim "89010250203552d538a6981e396d648999f2a62d" |
||
</source> |
</source> |
Revision as of 17:37, 22 October 2014
<source lang="haskell"> /* Stdenv v 0.4
* * To be run once, create some useful standard objects, and save * as a commit structure (for later loading into stdenv-s). * * Create some useful primitives from the base commands, * 'typeof' = λ (t:⋆) (x:t) → t -- compilation step not yet complete (and presently skipped) * 'commit' : {} -> IO(string) * 'open' : string -> {} -- retrieve a previously committed dir. * 'Prim' : string -> ? -- outputs a prim * 'Base' : string -> ⋆ -- outputs the type of a base object */
-- Test types Nat : ⋆ Z : Nat Succ : Nat → Nat
-- Simple functions id = λ x → x seq = λ a b → b const = λ a b → a flip = λ f a b → f b a
>>= = applyIO =<< = flip (>>=) >> = λ a b → applyIO a (const b) infixl >>= 1 infixr =<< 1 infixl >> 1
-- $ : <a,b : 'kind> -> (a -> b) -> a -> b $ : (a -> b) -> a -> b $ = fun f x -> f x infixr $ 0
IO : (a : 'kind) -> 'kind ST : (a : 'kind) (r : 'kind) -> 'kind
rm := Prim =<< commit {
name = "rm", ptype = type String -> IO(Nil), n=1, extn = 1, -- IO prim API = "", reduce = "
- include <ast.h>
- include <cli.h>
Ast *reduce(prim_cb_t *cb, struct Prim *p) {
struct Environ *e = (struct Environ *)cb->st;
if(p->t[0]->type != TBase || p->t[0]->base->type != TString) { printf(\"rm() called on non-string\\n\"); return mkNil(); }
p9remove(e, p->t[0]->base->name); return mkNil();
}", }
/* More work to do: unitIO applyIO unitST applyST
rm pwd ls cd open gc_stat
- /
-- Save current project as a commit. -- commit_proj "stdenv-0.2"
unApply = Prim "1572ad8f02e44c195ee3cfff433f0fa81df75268"
-- string cat ++ = Prim "04abdf66335ce0504c9e7a1707445e2f700fc185" -- string slice !% = Prim "992740f62d4ca2f2ca9f6f6cf9274d8b9626a7c2" strlen = Prim "2081afb248e480a8f6ca6220156c69d7ac938ef8" infixl ++ 4 infix !% 5
sleep = Prim "89010250203552d538a6981e396d648999f2a62d" </source>