2013-02-17 55 views

回答

2

它看起來像是,不是嗎?

{-# LANGUAGE FlexibleInstances #-} 

import Data.List 

data S s = T s | S [S s] deriving (Eq) 

instance Show (S String) where 
show (T s) = s 
show (S list) = "(" ++ (intercalate " " $ map show list) ++ ")" 

sExpr = S [T "define",T "x",T "10",S [T "print",T "hello"],S []] 

main = do 
putStrLn $ show sExpr 

運行的結果主要:

(define x 10 (print hello)())