我正在为Coursera的AI Planning课程编写一个Lispy PDDL解析器。
如何在Haskell中定义Lispy数据类型?
答案 0 :(得分:2)
它看起来像Lispy,不是吗?
{-# 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
运行main的结果:
(define x 10 (print hello) ())
答案 1 :(得分:0)
My Lispy PDDL Parser:
https://dl.dropbox.com/u/46434672/Code/LispyPddlParser.hs
DWR-operators.txt文件:
https://spark-public.s3.amazonaws.com/aiplan/resources/DWR-operators.txt