diff options
author | Bas van Dijk <v.dijk.bas@gmail.com> | 2012-11-19 16:09:02 +0100 |
---|---|---|
committer | Ian Lynagh <ian@well-typed.com> | 2013-02-17 18:08:38 +0000 |
commit | b7fc72ba714f71ca44b6d79845078cd62b57d285 (patch) | |
tree | 947e0b0a6b8d08d6f5b4713f94c386cb86943036 /libraries/base/System/Console | |
parent | 309c3a340f06e23c87997af127eed17cee9b14bf (diff) | |
download | haskell-b7fc72ba714f71ca44b6d79845078cd62b57d285.tar.gz |
Define Functor instances for ArgOrder, OptDescr and ArgDescr
Diffstat (limited to 'libraries/base/System/Console')
-rw-r--r-- | libraries/base/System/Console/GetOpt.hs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/libraries/base/System/Console/GetOpt.hs b/libraries/base/System/Console/GetOpt.hs index 1ea082963d..5bdb6d11d1 100644 --- a/libraries/base/System/Console/GetOpt.hs +++ b/libraries/base/System/Console/GetOpt.hs @@ -98,6 +98,19 @@ data ArgDescr a | ReqArg (String -> a) String -- ^ option requires argument | OptArg (Maybe String -> a) String -- ^ optional argument +instance Functor ArgOrder where + fmap _ RequireOrder = RequireOrder + fmap _ Permute = Permute + fmap f (ReturnInOrder g) = ReturnInOrder (f . g) + +instance Functor OptDescr where + fmap f (Option a b argDescr c) = Option a b (fmap f argDescr) c + +instance Functor ArgDescr where + fmap f (NoArg a) = NoArg (f a) + fmap f (ReqArg g s) = ReqArg (f . g) s + fmap f (OptArg g s) = OptArg (f . g) s + data OptKind a -- kind of cmd line arg (internal use only): = Opt a -- an option | UnreqOpt String -- an un-recognized option |