From 1af150e798c1580be42bc9e8f3880edbeb6fef29 Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Wed, 27 Apr 2016 10:37:13 +0200 Subject: Nicer cli --- Smurf.icl | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'Smurf.icl') diff --git a/Smurf.icl b/Smurf.icl index f00ef65..00da0aa 100644 --- a/Smurf.icl +++ b/Smurf.icl @@ -12,8 +12,14 @@ import Control.Applicative import Control.Monad import Data.Maybe +import GenEq + import SmurfParse +derive gEq Stm + +instance == Stm where == a b = a === b + instance zero [a] where zero = [] instance toString Stm @@ -29,6 +35,21 @@ where toString Get = "g" toString Exec = "x" +instance toChar Stm where toChar stm = (toString stm).[0] + +instance fromChar Stm +where + fromChar '"' = Push "" + fromChar 'i' = Input + fromChar 'o' = Output + fromChar '+' = Cat + fromChar 'h' = Head + fromChar 't' = Tail + fromChar 'q' = Quotify + fromChar 'p' = Put + fromChar 'g' = Get + fromChar 'x' = Exec + instance zero State where zero = { stack = zero, store = zero } instance toString State -- cgit v1.2.3