堆栈runghc与堆栈ghci Haskell产生的不同结果

问题描述 投票:0回答:1

我正在使用Megaparsec编写解析器。基本上,主文件将打开并读取文件的内容,然后解析该内容。在ghci中运行主文件时,所有内容均正确生成img-1

但是当我尝试使用堆栈runghc-app / Main.hs运行Main文件时,发生了奇怪的解析错误:img-2

这里是GitHub上的项目:https://github.com/phuongduyphan/dbml-parser-haskell

某人可以看一下,告诉我我做错了什么吗?为什么运行相同的main函数会导致堆栈ghci和堆栈runghc的输出不同?

haskell haskell-stack megaparsec
1个回答
1
投票

我克隆了您的存储库并尝试:

stack runghc -- app/Main.hs holistics.dbml

得到了:

Right 
( DBMLState 
    { tableS = fromList 
        [ 
            ( 0
            , NTable 
                { ntId = 0
                , ntGroupId = Nothing
                , ntName = "users" 
                , ntTableSettings = Nothing
                , ntFieldIds = [ 0 ]
                , ntIndexIds = []
                } 
            ) 
        ]
    , enumS = fromList []
    , refS = fromList []
    , tableGroupS = fromList []
    , fieldS = fromList 
        [ 
            ( 0
            , NField 
                { nfId = 0
                , nfTableId = 0
                , nfEnumId = Nothing
                , nfName = "id" 
                , nfType = "int" 
                , nfFieldSettings = Just [ FieldNote "abc" ]
                } 
            ) 
        ]
    , indexS = fromList []
    , endpointS = fromList []
    , tableIdCounter = 1
    , enumIdCounter = 0
    , refIdCounter = 0
    , tableGroupIdCounter = 0
    , fieldIdCounter = 1
    , indexIdCounter = 0
    , endpointIdCounter = 0
    } 
)

该问题可能与如何设置堆栈或本地开发环境有关。供参考,正在运行

stack --version

给我

Version 2.1.3, Git revision 636e3a759d51127df2b62f90772def126cdf6d1f (7735 commits) x86_64 hpack-0.31.2

更新或重新安装堆栈可能是一种解决方案。

© www.soinside.com 2019 - 2024. All rights reserved.