Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

runtime error with newtype declarations #44

Open
epsilonhalbe opened this issue Jun 8, 2017 · 0 comments
Open

runtime error with newtype declarations #44

epsilonhalbe opened this issue Jun 8, 2017 · 0 comments

Comments

@epsilonhalbe
Copy link

Here is a minimal showcase of the error I am facing:

If I declare a newtype datatype - then flags produce runtime errors.
For data-declarations everything seems to work just fine.

{-# LANGUAGE DeriveDataTypeable #-}
module Main where

import System.Console.CmdArgs
---------------------------------------------------------------------------------
--                 Newtypes seem to make problems with CMDARGS                 --
---------------------------------------------------------------------------------

newtype NewtypeSample = NewtypeSample {helloNT :: FilePath } deriving (Show, Data, Typeable)

worksNT = NewtypeSample{helloNT = def &= help "World argument" }
         &= summary "NewtypeSample v1"

doesn'tWorkNT1 = NewtypeSample{helloNT = def &= help "World argument" &= opt "world" &= typFile}
         &= summary "NewtypeSample v1"

doesn'tWorkNT2 = NewtypeSample{helloNT = def &= help "World argument" &= opt "world"}
         &= summary "NewtypeSample v1"

---------------------------------------------------------------------------------
--                  Data declarations seem to work just fine                   --
---------------------------------------------------------------------------------

data DataSample = DataSample {helloD :: FilePath } deriving (Show, Data, Typeable)

worksD1 = DataSample{helloD = def &= help "World argument" &= opt "world"}
         &= summary "DataSample v1"

worksD2= DataSample{helloD = def &= help "World argument" &= opt "world" &= typFile}
         &= summary "DataSample v1"

main :: IO ()
main = do 
  print =<< cmdArgs doesn'tWorkNT1
  print =<< cmdArgs doesn'tWorkNT2
  print =<< cmdArgs worksNT
  print =<< cmdArgs worksD1
  print =<< cmdArgs worksD2
  return ()

Here are the errors I get:

  • doesn'tWorkNT1
stack build && stack exec -- cmdargsbug
cmdargsbug-0.1.0.0: build (exe)
Preprocessing executable 'cmdargsbug' for cmdargsbug-0.1.0.0...
[1 of 1] Compiling Main             ( src/Main.hs, .stack-work/dist/x86_64-linux/Cabal-1.24.2.0/build/cmdargsbug/cmdargsbug-tmp/Main.o )
Linking .stack-work/dist/x86_64-linux/Cabal-1.24.2.0/build/cmdargsbug/cmdargsbug ...
cmdargsbug-0.1.0.0: copy/register
Installing executable(s) in
..../cmdargsbug/.stack-work/install/x86_64-linux/lts-8.17/8.0.2/bin
cmdargsbug: System.Console.CmdArgs.Implicit, unexpected mode: FlagType "FILE"
CallStack (from HasCallStack):
  error, called at ./System/Console/CmdArgs/Implicit/Local.hs:106:11 in cmdargs-0.10.17-IWa8ygdJhnJBShkQXN8V9I:System.Console.CmdArgs.Implicit.Local

commenting out the doesn'tWorkNT1 line produces

  • doesn'tWorkNT2
stack build && stack exec -- cmdargsbug
cmdargsbug-0.1.0.0: build (exe)
Preprocessing executable 'cmdargsbug' for cmdargsbug-0.1.0.0...
[1 of 1] Compiling Main             ( src/Main.hs, .stack-work/dist/x86_64-linux/Cabal-1.24.2.0/build/cmdargsbug/cmdargsbug-tmp/Main.o )
Linking .stack-work/dist/x86_64-linux/Cabal-1.24.2.0/build/cmdargsbug/cmdargsbug ...
cmdargsbug-0.1.0.0: copy/register
Installing executable(s) in
..../cmdargsbug/.stack-work/install/x86_64-linux/lts-8.17/8.0.2/bin
cmdargsbug: System.Console.CmdArgs.Implicit, unexpected mode: FlagOptional "world"
CallStack (from HasCallStack):
  error, called at ./System/Console/CmdArgs/Implicit/Local.hs:106:11 in cmdargs-0.10.17-IWa8ygdJhnJBShkQXN8V9I:System.Console.CmdArgs.Implicit.Local
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant