Quantcast
Channel: How to write an expression over a data type and print it out in haskell? - Stack Overflow
Browsing latest articles
Browse All 2 View Live

Answer by Zeta for How to write an expression over a data type and print it...

First of all, expr has the wrong type. expr :: Poly would be correct. You could also ask GHCi about that type:> :t Add (Lit 1) $ Add (Var) $ Mul (Var) $ Mul Var VarAdd (Lit 1) $ Add (Var) $ Mul...

View Article


How to write an expression over a data type and print it out in haskell?

I am having to write an expression to construct a Poly representation of the polynomial x^3 + x + 1.My algebraic data type Poly, which I wrote is:data Poly = Lit Integer | Var | Add Poly Poly | Mul...

View Article

Browsing latest articles
Browse All 2 View Live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>