[commit: base] master: Define Functor instances for ArgOrder, OptDescr and ArgDescr (c089588)
Ian Lynagh
igloo at earth.li
Sun Feb 17 21:57:42 CET 2013
Repository : ssh://darcs.haskell.org//srv/darcs/packages/base
On branch : master
http://hackage.haskell.org/trac/ghc/changeset/c089588bbf486495d548ea045ba9cc219aef3213
>---------------------------------------------------------------
commit c089588bbf486495d548ea045ba9cc219aef3213
Author: Bas van Dijk <v.dijk.bas at gmail.com>
Date: Mon Nov 19 16:09:02 2012 +0100
Define Functor instances for ArgOrder, OptDescr and ArgDescr
>---------------------------------------------------------------
System/Console/GetOpt.hs | 13 +++++++++++++
1 files changed, 13 insertions(+), 0 deletions(-)
diff --git a/System/Console/GetOpt.hs b/System/Console/GetOpt.hs
index 1ea0829..5bdb6d1 100644
--- a/System/Console/GetOpt.hs
+++ b/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
More information about the ghc-commits
mailing list