Haskell: Why is it saying my function type is off?
Posted
by linkmaster03
on Stack Overflow
See other posts from Stack Overflow
or by linkmaster03
Published on 2010-04-06T23:19:42Z
Indexed on
2010/04/06
23:23 UTC
Read the original article
Hit count: 195
haskell
|functional-programming
I wrote a little Haskell program to find the area of a triangle, primarily to practice custom types, but it keeps throwing the following error on compile:
areafinder.hs:7:4:
Couldn't match expected type 'Triangle' against inferred type 'm b'
In a stmt of a 'do' expression: putStr "Base: "
In the expression:
do { putStr "Base: ";
baseStr
I'm not sure where 'm b' comes from, so I'm at a loss here. Why is it throwing this error, and what can I do to fix it? Here is my code:
module Main where data Triangle = Triangle Double Double -- base, height getTriangle :: Triangle getTriangle = do putStr "Base: " baseStr Double calcTriangle (Triangle base height) = base * height main = putStrLn ("Area = " ++ show (calcTriangle getTriangle))
Thanks. :)
© Stack Overflow or respective owner