Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4250210
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T04:29:55+00:00 2026-05-21T04:29:55+00:00

I have the following snippet, which compiles fine, but when I try to run

  • 0

I have the following snippet, which compiles fine, but when I try to run it I get an error from cmdargs. *** Exception: System.Console.CmdArgs.Implicit, unexpected flag (edit): Main.Sel. It works if I change the Sel to Int, but in my real use case I’d like to have type enforcement that differentiates selections from Ints.

I can fix it by using Int with cmdargs and after checking the arguments casting it to Sel, but I think this is suboptimal solution.

{-# LANGUAGE DeriveDataTypeable, GeneralizedNewtypeDeriving #-}
import System.Console.CmdArgs
import System.Console.CmdArgs.Default

newtype Sel = Sel Int deriving (Num, Real, Integral, Show, Read, Data, Typeable, Enum, Eq, Ord, Default)

data Foo = Foo {
    edit :: Sel
  } deriving (Show, Read, Data, Typeable)

foo = Foo {
  edit = def
  }
main = do
  a <- cmdArgs foo
  print a
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T04:29:56+00:00Added an answer on May 21, 2026 at 4:29 am

    It is suboptimal indeed, and I’ve raised a bug to track the addition of this feature: http://code.google.com/p/ndmitchell/issues/detail?id=422

    I might have time to work on it this weekend, it shouldn’t be too hard (but depends how much further than newtypes I want to go). (For context, I wrote cmdargs)

    Update: I just released cmdargs 0.6.9 on Hackage which supports newtypes as requested in this question.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have the following code snippet in my ANT File which compiles my project
I have the following very simple code snippet which is loaded from a separate
I have the following code snippet which is working fine: ifstream NDSConfig( NDS.config )
I have the following snippet which i use to load xml via jQuery from
I have the following snippet in my pom.xml (Full pom attached below which can
i have the following code snippet. in which i just want to return PartyName
I have following code snippet that i use to compile class at the run
I have the following snippet from my code: switch ($extention) { case gif: $src
This snippet (taken from this question ) compiles fine with g++ (as seen), so
I have the following snippet calling a perl script which writes to STDERR and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.