[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

$ 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:
collect2: ld returned 1 exit status

Here are my files:

module Main () where

import SimpleJSON 
import PrettyJSON
import Prettify

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


module SimpleJSON
    ) where 

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


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 

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