From b7fc72ba714f71ca44b6d79845078cd62b57d285 Mon Sep 17 00:00:00 2001 From: Bas van Dijk Date: Mon, 19 Nov 2012 16:09:02 +0100 Subject: Define Functor instances for ArgOrder, OptDescr and ArgDescr --- libraries/base/System/Console/GetOpt.hs | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'libraries/base') 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 -- cgit v1.2.1