Browse files

Oops, that wasn't a monoid instance...

  • Loading branch information...
1 parent 449714f commit 057f37df1299318598c6e0db95e3ee2131234f54 @gregorycollins committed Feb 4, 2009
Showing with 10 additions and 5 deletions.
  1. +10 −5 Main.hs
View
15 Main.hs
@@ -145,10 +145,15 @@ data Options = Options {
} deriving (Eq, Show)
+defaultOptions = Options { installPrefix = Just "/usr/local"
+ , showUsage = False
+ , packageMakerPath = Just "/Developer/usr/bin/packagemaker"
+ }
+
instance Monoid Options where
- mempty = Options { installPrefix = Just "/usr/local"
+ mempty = Options { installPrefix = Nothing
, showUsage = False
- , packageMakerPath = Just "/Developer/usr/bin/packagemaker"
+ , packageMakerPath = Nothing
}
a `mappend` b =
@@ -158,8 +163,8 @@ instance Monoid Options where
, showUsage = showUsage a || showUsage b
}
where
- (+) a b = getLast $ (Last a) `mappend` (Last b)
- override f = (f a) + (f b)
+ a *+* b = getLast $ Last a `mappend` Last b
+ override f = f a *+* f b
------------------------------------------------------------------------
@@ -213,7 +218,7 @@ getOptions = do
args <- getArgs
opts <-
case GetOpt.getOpt GetOpt.RequireOrder optionFlags args of
- (o,n,[]) -> return $ mconcat o
+ (o,n,[]) -> return $ defaultOptions `mappend` mconcat o
(_,_,errs) -> usage errs
if showUsage opts

0 comments on commit 057f37d

Please sign in to comment.