Skip to content

Commit

Permalink
Make 'viewAsFieldDescr' a total function.
Browse files Browse the repository at this point in the history
Fixes haskell#980 by allowing to create config fields from options with optional
arguments. Without this change, setting the 'jobs' or 'verbose' fields in the
config file results in a fatal error on startup.
  • Loading branch information
23Skidoo authored and tibbe committed Aug 16, 2012
1 parent c247ec7 commit d50b2d3
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Cabal/Distribution/Simple/Command.hs
Expand Up @@ -270,9 +270,9 @@ viewAsFieldDescr (OptionField n dd) = FieldDescr n get set
Just f -> return (f a)
_ -> syntaxError line val
BoolOpt _ _ _ setV _ -> (`setV` a) `liftM` runP line n parse val
OptArg _ _ _ _readE _ _ -> -- The behaviour in this case is not clear, and it has no use so far,
-- so we avoid future surprises by not implementing it.
error "Command.optionToFieldDescr: feature not implemented"
OptArg _ _ _ readE _ _ -> ($ a) `liftM` runE line n readE val
-- Optional arguments are parsed just like required arguments here;
-- we don't provide a method to set an OptArg field to the default value.

getChoiceByLongFlag :: OptDescr b -> String -> Maybe (b->b)
getChoiceByLongFlag (ChoiceOpt alts) val = listToMaybe [ set | (_,(_sf,lf:_), set, _) <- alts
Expand Down

0 comments on commit d50b2d3

Please sign in to comment.