[Haskell-beginners] having trouble compiling

7stud bbxx789_05ss at yahoo.com
Fri Mar 27 05:51:23 EDT 2009


Here is the error I am getting (I always get the first warning so that is nothing
new):

$ ghc -o Main.hs SimpleJSON.hs PrettyJSON.hs Prettify.hs
compilation IS NOT required
compilation IS NOT required
/usr/libexec/gcc/i686-apple-darwin8/4.0.1/ld: warning -F: directory name 
(/Users/me/Library/Frameworks) does not exist

/usr/libexec/gcc/i686-apple-darwin8/4.0.1/ld: Undefined symbols:
_ZCMain_main_closure
___stginit_ZCMain
collect2: ld returned 1 exit status


Here are my files:

Main.hs
-----
module Main () where

import SimpleJSON 
import PrettyJSON
import Prettify

main = let s = JString "hello world" 
           aDoc = renderJValue s
       in printPrettified aDoc



SimpleJSON.hs
--------

module SimpleJSON
    (
     JValue(..)
    ) where 

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



PrettyJSON.hs:
-------

module PrettyJSON where

import SimpleJSON 
import Prettify 

renderJValue :: JValue -> Doc
renderJValue (JNumber f)    = DNumber f
renderJValue (JString s)    = DText s 
renderJValue (JBool True)   = DBool True
renderJValue (JBool False)  = DBool False
renderJValue JNull          = DNull 



Prettify.hs:
------
module Prettify where

data Doc = DNumber Double
         | DText String
         | DBool Bool
         | DNull 
           deriving (Show)
         

getPrettyOutput :: Doc -> String
getPrettyOutput (DNumber d)     = "double: " ++ show d
getPrettyOutput (DText s)       = "string: " ++ show s
getPrettyOutput (DBool True)    = "bool: true"
getPrettyOutput (DBool False)   = "bool: false"
getPrettyOutput DNull           = "null"
         

printPrettfied :: Doc -> IO ()
printPrettified aDoc = putStrLn (getPrettyOutput aDoc)








More information about the Beginners mailing list