Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The IO action ‘main’ is not exported by module ‘Main’

Tags:

haskell

I have two haskell files named SimpleJSON.hs and another is Main.hs

--File: SimpleJSON.hs
module SimpleJSON
(
    JValue (..)
    ,getString
    ,getInt
    ,getDouble
    ,getBool
    ,getObject
    ,getArray
    ,isNull
) where

data JValue = JString String
        | JNumber Double
        | JBool Bool
        | JNull
        | JObject [(String, JValue)]
        | JArray [JValue]
          deriving (Eq, Ord, Show)

And

--File: Main.hs
module Main () where
import SimpleJSON
main = print (JObject [("foo", JNumber 1), ("bar", JBool False)])

So while compiling I am doing

ghc -c SimpleJSON.hs

and

ghc simple Main.hs SimpleJSON.o

Then I am getting error as

Main.hs:1:1: error:
The IO action ‘main’ is not exported by module ‘Main’
  |
1 | module Main () where
  | ^

How to resolve this compilation error?

like image 445
Saurabh kukade Avatar asked Dec 08 '18 17:12

Saurabh kukade


1 Answers

Should be

module Main where

or

module Main (main) where
like image 144
mb21 Avatar answered Sep 30 '22 17:09

mb21