feat(haskell): CLI rewrite
This commit is contained in:
@@ -8,8 +8,6 @@ import Data.Map ()
|
||||
import Data.Text (Text, replace)
|
||||
import Data.Text.Encoding (decodeUtf8, encodeUtf8)
|
||||
import Data.Word (Word8)
|
||||
import System.Console.CmdArgs (Data, Typeable)
|
||||
|
||||
import qualified Data.ByteString as BS
|
||||
import qualified Data.Map as Map
|
||||
import qualified Data.Set as Set
|
||||
@@ -55,8 +53,8 @@ data LToken
|
||||
deriving (Eq, Show, Ord)
|
||||
|
||||
-- Output formats
|
||||
data EvaluatedForm = TreeCalculus | FSL | AST | Ternary | Ascii | Decode
|
||||
deriving (Show, Data, Typeable)
|
||||
data EvaluatedForm = Tree | FSL | AST | Ternary | Ascii | Decode
|
||||
deriving (Show)
|
||||
|
||||
-- Environment containing previously evaluated TC terms
|
||||
type Env = Map.Map String T
|
||||
@@ -243,7 +241,7 @@ toList _ = Left "Invalid Tree Calculus list"
|
||||
|
||||
-- Outputs
|
||||
formatT :: EvaluatedForm -> T -> String
|
||||
formatT TreeCalculus = toSimpleT . show
|
||||
formatT Tree = toSimpleT . show
|
||||
formatT FSL = show
|
||||
formatT AST = show . toAST
|
||||
formatT Ternary = toTernaryString
|
||||
@@ -289,7 +287,7 @@ decodeResult tc =
|
||||
(_, _, Right n) -> show n
|
||||
(_, Right xs@(_:_), _) -> "[" ++ intercalate ", " (map decodeResult xs) ++ "]"
|
||||
(_, Right [], _) -> "[]"
|
||||
_ -> formatT TreeCalculus tc
|
||||
_ -> formatT Tree tc
|
||||
where
|
||||
isCommonChar c =
|
||||
let n = fromEnum c
|
||||
|
||||
Reference in New Issue
Block a user