Skip to content

Instantly share code, notes, and snippets.

View joel-costigliola's full-sized avatar

Joel Costigliola joel-costigliola

  • Gentrack
  • Auckland
View GitHub Profile
@vertexcite
vertexcite / eval.hs
Created April 28, 2015 05:26
Monad example: simple expression evaluation - for Auckland FP Meetup 2015-04-28. By Steve Reeves
---Very simple evaluation for arithmetic expressions with only constants
---(and only "plus"...obviously extendable to other operations)
data Expr = C Float |
Expr :+ Expr
deriving Show
eval :: Expr -> Float
eval (C x) = x
eval (e1 :+ e2) = let v1 = eval e1