Haskell: Why is it saying my function type is off?

The getTriangle function uses IO, so you have to put that in the function signature getTriangle :: IO Triangle Also, the last line should have return since it's returning a pure value inside an IO function return (Triangle base height) Here are a couple extra tips: Haskell can figure out that base and height are Double because you pass them to Triangle so you don't need to explicitly declare them that way. You can use liftM from the Control. Monad module to read the input and convert to Double in one step import Control.

Monad getTriangle :: IO Triangle getTriangle = do putStr "Base: " base > liftM read getLine getTriangle = liftM2 Triangle (prompt "Base") (prompt "Height").

The getTriangle function uses IO, so you have to put that in the function signature. GetTriangle :: IO Triangle Also, the last line should have return, since it's returning a pure value inside an IO function. Return (Triangle base height) Here are a couple extra tips: Haskell can figure out that base and height are Double, because you pass them to Triangle, so you don't need to explicitly declare them that way.

You can use liftM from the Control. Monad module to read the input and convert to Double in one step. Import Control.

Monad getTriangle :: IO Triangle getTriangle = do putStr "Base: " base > liftM read getLine getTriangle = liftM2 Triangle (prompt "Base") (prompt "Height").

Thanks for the great explanation! Functional programming is still a bit difficult for me, but I'm getting it. Also, I have no clue how I forgot the division in the formula.

:) – linkmaster03 Apr 6 '10 at 23:38.

Note that you can drop getTriangle :: Triangle and by running :t getTriangle that the hugs/ghci prompt it will tell you what it thinks the types should be.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions