Reputation:
data Figura = Circulo Float | Rectangulo Float Float
esRedondo :: Figura -> Bool
esRedondo (Circulo _) = True
esRedondo (Rectangulo _ _) = False
area :: Figura -> Float
area (Circulo r) = pi*r*r
area (Rectangulo h b) = h*b
I get an error :
The function
main' is not defined in module `Main'
Upvotes: 1
Views: 136
Reputation: 3216
There are two reasons why this happens:
Main
module.The sum of this two reasons gives your error: no main
function in the Main
module.
One solution could be to add the main
function:
main :: IO ()
main = return () -- do nothing
or, in alternative, compile your file as a library and then load it in ghci
(or just load the .hs
file in ghci
). In this case you should give a module name to your library:
module Geometry where
[...]
and then import it where you use it with import Geometry
.
Upvotes: 0
Reputation: 10941
Here is what you probably want to do if you are using ghc. Do ghci yourprogram.hs
. This will allow to interact with your program interactively. Your program doesn't currently do anything by itself, so this will be more useful.
Upvotes: 2
Reputation: 370082
If you want to create a runnable executable, you need to define main :: IO ()
, which will be executed when the program is run.
Upvotes: 5