Commit 0e9d51c7 authored by Reg Huijben's avatar Reg Huijben

Shit no worky

parent 76e3132b
......@@ -84,7 +84,7 @@ class action v where
//:: Upd = Upd
class var v where
(=.) infixr 2 :: (v Var Int) (v Expr Int) -> v Action (Step a a) //| type t
var :: (v Var t) -> (v Expr t) | type t
var :: (v Var Int) -> (v Expr Int) //| type t
int :: (v Expr Int) ((v Var Int) -> (v p u)) -> v p u //| type t
//(v Expr t) ((v Action t) -> v Expr z) -> v Expr y | type t//int :: (v Expr t) ((v Expr t) -> (v Action u)) -> v Action u | type t
//int :: (v Expr t) ((v q t) -> (v p t)) -> v r t | type t //(v Expr t) ((v Action t) -> v Expr z) -> v Expr y | type t
......@@ -254,29 +254,39 @@ instance var Show where
rvar :: Int State -> (Result Int, State) //| TC a
//rvar :: Int State -> (Result Int, State) //| TC a
//rvar n s = (Res a,{s & map = put n a s.map})
rvar n s = case get n s.map of
(Just d) = (Res d,s)
_ = (Err "undefined",s)
//rvar n s = case get n s.map of
// (Just d) = (Res d,s)
// _ = (Err "undefined",s)
//:: Var = Var Id
//:: Id :== Int
// defined below!
:: RW t = R | W t
rwvar :: Int (RW Int) State -> (Result Int, State)
rwvar n R s = case get n s.map of
(Just d) = (Res d,s)
_ = (Err "undefined",s)
rwvar n (W a) s = (Res a,{s & map = put n a s.map})
instance var Eval where
//(=.) infixr 2 :: (v Var t) (v Expr t) -> v Action (Step a a) | type t
(=.) v e = Eval \sss. let (g,s) = (unEval e) sss in
//let (Res h,s) = (unEval v) ss in
(Res (undef), {s & map = put 4 8 s.map } )
var n = Eval \s. (unEval n) s
(=.) v e = Eval \sss.
case (unEval v) sss of
(Res (h),ss) -> trace h let (Res g,s) = (unEval e) ss in (Res (undef), {s & map = put h g s.map } )
(Res (undef),ss) -> trace "noper" undef
(Err e,ss) -> trace e undef
_ -> trace "nope" undef
var n = Eval \s. let (Res g, ss) = (unEval n) s in trace g
case (get g ss.map) of
Nothing -> (Err "undef var", ss)
Just(a)-> ((Res a),ss)
//(=.) v e = e >>- \a.Eval \r s.unEval v a s
// This needs to return a (State -> (Result v0, State))
......@@ -291,9 +301,18 @@ instance var Eval where
(Res rslt,zz) -> unEval ( (f (Eval (rvar zz.vars )) ))
{zz & vars = inc zz.vars, map = put zz.vars rslt zz.map}
*/
int x f = Eval \s. case ((unEval x) s) of
(Res rslt,zz) -> unEval ( (f (Eval (rvar zz.vars )) )) {zz & vars = inc zz.vars, map = put zz.vars rslt zz.map}
_ -> trace "nope" undef
// int x f = Eval \r s. unEval (f (Eval (rwvar s.vars) )) R s
int x f = Eval \s. let (Res rslt,zz) = ((unEval x) s) in
(unEval (f (Eval \z.(rwvar z.vars (W z.vars) z) )))
{zz & vars = inc zz.vars, map = put zz.vars rslt zz.map}
//:: Eval p t = Eval (State -> (Result t, State))
//{s & vars = inc s.vars, map = put s.vars x s.map}
......@@ -435,16 +454,16 @@ zoepie [a:r] = a +++ zoepie r
zoepie [] = ""
loadShipzzz = int (lit 5) \n. n =. lit 1
loadShipzzz = int (lit 6) \z. int (lit 7) \s. (var s) //int ((lit 9) +. (lit 4)) \n. (var n) +. (lit 5) //int (lit 9) \z. int (lit 5) (\n. int (var n +. lit 70) \x. lit 6 )
loadShipzz = int (lit 5) \n. var n +. lit 1//int (lit 5) \s. int (lit 0) \n. While (var n <. containersBelow) (
//moveDown :. lock :. moveUp:. moveToShip :. moveDown :. unlock :. moveUp:. moveToQuay :. (n =. (lit 5))
//)
//Start = let (Show f) = loadShipw in zoepie (reverse (snd( f s0)).print)
Start = let (Eval f) = loadShipzzz in
Start = let (Show f) = loadShipw in zoepie (reverse (snd( f s0)).print)
//Start = let (Eval f) = loadShipzzz in
//get 0 (snd ( f initialState)).map
snd (f initialState)
// (f initialState)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment