S-expressions: Difference between revisions

Content added Content deleted
Line 3,083: Line 3,083:
atom s@('"' : _) =
atom s@('"' : _) =
fromMaybe (List []) (maybeRead ("String " <> s))
fromMaybe (List []) (maybeRead ("String " <> s))
atom s = firstParse parses
atom s =
headDef (List []) $
where
catMaybes $
firstParse (x : _) = x
parses =
maybeRead
<$> ( fmap (<> (' ' : s)) ["Int", "Float"]
catMaybes $
<> ["Symbol \"" <> s <> "\""]
maybeRead
<$> ( fmap
)

(<> (' ' : s))
headDef :: a -> [a] -> a
["Int", "Float"]
headDef d [] = d
<> ["Symbol \"" <> s <> "\""]
)
headDef _ (x : _) = x


maybeRead :: String -> Maybe Val
maybeRead :: String -> Maybe Val