Skip to content

Instantly share code, notes, and snippets.

@joshcough
Created March 7, 2015 18:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joshcough/53e3b48e2e07f17f4786 to your computer and use it in GitHub Desktop.
Save joshcough/53e3b48e2e07f17f4786 to your computer and use it in GitHub Desktop.
instance (Eq a, FromSExpr a) => FromSExpr (E a) where
fromSExpr (List [AtomSym "lambda", List args, b]) = do
e <- fromSExpr b
as <- sequence $ fmap fromSExpr args
return $ Lambda (length args) $ abstract (flip elemIndex as) e
--if wellFormedArgList args
-- then return $ Lambda (length args) $ abstract (flip elemIndex as) e
-- else fail $ "bad arguments" ++ show args -- fail if args is ill formed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment