tags:

views:

55

answers:

1

[Source Code]

data FooBar = Foo | Bar

[Command]

$ ghc -c foo_bar.hs
foo_bar.hs:1:0: The function 'main' is not defined in module 'Main'

[Configuration]

Glasgow Haskell Compiler, Version 6.12.3, for Haskell 98, stage 2 booted by GHC version 6.10.4

+2  A: 

You should define your type in a module, and then compile it:

module Test where
data FooBar = Foo | Bar

By invoking ghc -c foo_bar.hs, the object file foo_bar.o will be generated without having to define main.

Giu
$ ghc -c -no-hs-main foo_bar.hs foo_bar.hs:1:0: The function `main' is not defined in module `Main'
aXqd
@aXqd Wrong hint, sorry. I've updated my answer. I've tested it locally, and it works; the object file will be generated.
Giu