S-expressions: Difference between revisions

m
Line 3,035:
import Data.Tree (Tree (..), drawForest)
 
------------------------ DATA TYPESTYPE -----------------------
 
data Val
Line 3,044:
| List [Val]
deriving (Eq, Show, Read)
 
instance Semigroup Val where
(<>) (List a) (List b) = List (a <> b)
 
instance Monoid Val where
mempty = List []
 
--------------------------- MAIN -------------------------
Line 3,086 ⟶ 3,080:
 
atom :: String -> Val
atom [] = memptyList []
atom s@('"' : _) =
fromMaybe mempty(List []) (maybeRead ("String " <> s))
atom s = firstParse parses
where
firstParse [] = memptyList []
firstParse (x : _) = x
parses =
9,655

edits