Minor fix to REPL output for numbers
Uses # instead of text output. Adds several basic library functions.
This commit is contained in:
		
							
								
								
									
										39
									
								
								src/Main.hs
									
									
									
									
									
								
							
							
						
						
									
										39
									
								
								src/Main.hs
									
									
									
									
									
								
							| @ -17,14 +17,35 @@ runSapling s = show $ result (evalSapling Map.empty $ parseSapling s) | ||||
|  | ||||
| library :: Map.Map String T | ||||
| library = evalSapling Map.empty $ parseSapling | ||||
|       "false = t\n \  | ||||
|      \ true = t t\n \ | ||||
|      \ id = (\\a : a)\n \ | ||||
|      \ triage = (\\a b c : t (t a b) c)\n \ | ||||
|      \ match_bool = (\\ot of : triage of (\\z : ot) t)\n \ | ||||
|      \ and = match_bool id (\\z : false)\n \ | ||||
|      \ if = (\\cond then else : t (t else (t t then)) t cond)\n \ | ||||
|      \ triage = (\\a b c : t (t a b) c)\n \ | ||||
|      \ test = triage \"leaf\" (\\z : \"stem\") (\\a b : \"fork\")" | ||||
|    "false = t\n \  | ||||
|   \ k = t t\n \ | ||||
|   \ i = t (t k) t\n \ | ||||
|   \ s = t (t (k t)) t\n \ | ||||
|   \ m = s i i\n \ | ||||
|   \ b = s (k s) k\n \ | ||||
|   \ c = s (s (k s) (s (k k) s)) (k k)\n \ | ||||
|   \ iC = (\\a b c : s a (k c) b)\n \ | ||||
|   \ iD = b (b iC) iC\n \ | ||||
|   \ iE = b (b iD) iC\n \ | ||||
|   \ yi = (\\i : b m (c b (i m)))\n \ | ||||
|   \ y = yi iC\n \ | ||||
|   \ yC = yi iD\n \ | ||||
|   \ yD = yi iE \ | ||||
|   \ true = t t\n \ | ||||
|   \ id = (\\a : a)\n \ | ||||
|   \ triage = (\\a b c : t (t a b) c)\n \ | ||||
|   \ pair = t\n \ | ||||
|   \ matchBool = (\\ot of : triage of (\\z : ot) t)\n \ | ||||
|   \ matchList = (\\oe oc : triage oe _ oc)\n \ | ||||
|   \ matchPair = (\\op : triage _ _ op)\n \ | ||||
|   \ and = matchBool id (\\z : false)\n \ | ||||
|   \ if = (\\cond then else : t (t else (t t then)) t cond)\n \ | ||||
|   \ test = triage \"leaf\" (\\z : \"stem\") (\\a b : \"fork\")\n \ | ||||
|   \ emptyList = matchList true (\\y z : false)\n \ | ||||
|   \ nonEmptyList = matchList false (\\y z : true)\n \ | ||||
|   \ head = matchList t (\\hd tl : hd)\n \ | ||||
|   \ tail = matchList t (\\hd tl : tl)\n \ | ||||
|   \ listConcat = y (\\self : matchList (\\k : k) (\\h t k : pair h (self t k)))\n \ | ||||
|   \ listConcat \"foo\" \"bar\"" | ||||
|  | ||||
| runSaplingEnv env s = show $ result (evalSapling env $ parseSapling s) | ||||
|  | ||||
| @ -35,5 +35,5 @@ decodeResult tc = | ||||
|   case ofString tc of | ||||
|     Right str -> "\"" ++ str ++ "\"" | ||||
|     Left _ -> case ofNumber tc of | ||||
|       Right num -> "Number: " ++ show num | ||||
|       Right num -> "# " ++ show num | ||||
|       Left _ -> "Failed to decode number from Tree" | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 James Eversole
						James Eversole