0

I'm writing a parser using Megaparsec. Basically, the main file will open and read content of a file and then parsing that content. When running the main file in ghci, everything was produced correctly img-1

But when I tried running the Main file using stack runghc -- app/Main.hs, the weird parsing error happened: img-2

Here is the project on GitHub: https://github.com/phuongduyphan/dbml-parser-haskell

Could sb have a look and tell me what am I doing wrong ? Why running the same main function results in different outputs from stack ghci and stack runghc ?

Duy Phan
  • 27
  • 5

1 Answers1

2

I cloned your repository and tried:

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

And got:

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
    } 
)

The problem is likely a problem with how stack or the local development environment is set up. For reference, running

stack --version

Gives me

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

Updating or re-installing stack could be a possible solution.