Skip to content

Instantly share code, notes, and snippets.

@deque-blog
Created January 20, 2017 20:18
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 deque-blog/19249732fe7d18d3b8aae06fa7b338b2 to your computer and use it in GitHub Desktop.
Save deque-blog/19249732fe7d18d3b8aae06fa7b338b2 to your computer and use it in GitHub Desktop.
prn :: Expr -> String
prn = cata algebra where
algebra (Cst n) = show n
algebra (Var x) = x
algebra (Op Add xs) = "(+ " ++ unwords xs ++ ")"
algebra (Op Mul xs) = "(* " ++ unwords xs ++ ")"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment