ndmitchell / cmdargs

Haskell library for command line argument processing
Other
91 stars 12 forks source link

Data.Generics.Any: Undefined field inside compose0, :% :: Ratio Int #24

Closed andre-van-delden closed 9 years ago

andre-van-delden commented 9 years ago

Getting a runtime error on:

{-# LANGUAGE DeriveDataTypeable -}
module Main where

import Data.Ratio
import System.Console.CmdArgs

data Options = Options { r :: Ratio Int
                                      } deriving (Show, Data, Typeable)

defaultOptions = Options { r = 4 % 7 }

main = print =<< cmdArgs defaultOptions

The error message is: Data.Generics.Any: Undefined field inside compose0, :% :: Ratio Int

ndmitchell commented 9 years ago

The problem is that Ratio is defined with strict fields, specifically:

data  Ratio a = !a :% !a  deriving (Eq)

And that plays havoc with certain types of Data operations. Fortunately, I was able to fix it up relatively easily in this instance. I've released 0.10.13 with the fix.

While it's fixed, I didn't really expect people to pass Ratio on the command line, and it might not be as useful as you would hope.