0
我試圖用sourceline
於是我進口Text.Parsec.Pos(SourcePos,sourceLine)
走出SourcePos
的行號。 但是,創建SourcePos
的另一個模塊(Language.ECMAScript3.Syntax
)以其自己的類型導出,但不導出sourceLine
。相同的數據結構導入兩次,不能訪問底層數據
這沒有幫助。我得到這個錯誤:SRC \ Main.hs:62:53:
Couldn't match type `Text.Parsec.Pos.SourcePos' with `Language.ECMAScript3.Syntax.SourcePos' Expected type: JavaScript Language.ECMAScript3.Syntax.SourcePos -> [Char] Actual type: JavaScript Text.Parsec.Pos.SourcePos -> [Char] ....
list (one:rest) = case one of
(VarDeclStmt _ [VarDecl _ (Id ln a) _]) -> "\nvar "++ (show (sourceLine (ln))) ++ (show a)++ list rest
otherwise -> list rest
大背景下:
lookAtJsModule src label func =
case parseFromString src of
Left err -> "Can't parse a test-case: " ++
"\nThe error was " ++ (show err)
Right js -> label ++ (func js)
list0 tree = case tree of
(Script a b) -> list b
--list :: [Language.ECMAScript3.Syntax.Statement a] -> String
list (one:rest) = case one of
(VarDeclStmt _ [VarDecl _ (Id (ln) a) _]) -> "\nvar "++ (show ((ln ))) ++ (show a)++ list rest
otherwise -> list rest
list[] = ""
listSpecificModule src = lookAtJsModule src "list:" list0
listVars _ = do
content <- getContents
putStrLn(listSpecificModule內容)0
注意它是一樣」。有辦法,例如投下來解決這個問題?
你能證明傳給你的錯誤的代碼? – dfeuer
我添加了代碼。 – Aftershock
我們可能需要比這更多的代碼。你能發佈一個提供錯誤的最小*完整*例子,以及完整的錯誤。 –