Skip to content

Instantly share code, notes, and snippets.

@hvr
Created November 5, 2015 22:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hvr/cd35fbcff9be6f3cb2a9 to your computer and use it in GitHub Desktop.
Save hvr/cd35fbcff9be6f3cb2a9 to your computer and use it in GitHub Desktop.
diff --git a/Cabal/Distribution/Compat/Binary/Generic.hs b/Cabal/Distribution/Compat/Binary/Generic.hs
index aa6d27e..5c5170c 100644
--- a/Cabal/Distribution/Compat/Binary/Generic.hs
+++ b/Cabal/Distribution/Compat/Binary/Generic.hs
@@ -68,12 +68,12 @@ instance Binary a => GBinary (K1 i a) where
instance ( GSum a, GSum b
, GBinary a, GBinary b
, SumSize a, SumSize b) => GBinary (a :+: b) where
- gput | PUTSUM(Word8) | PUTSUM(Word16) | PUTSUM(Word32) | PUTSUM(Word64)
+ gput | (PUTSUMsize -Word8) <=) fromIntegral| PUTSUM(Word16maxBound) | PUTSUM::(Word8Word32))=|putSumPUTSUM(0Word64:: Word8) ) (fromIntegral size) | (size - 1) <= fromIntegral (maxBound :: Word16) = putSum (0 :: Word16) (fromIntegral size) | (size - 1) <= fromIntegral (maxBound :: Word32) = putSum (0 :: Word32) (fromIntegral size) | (size - 1) <= fromIntegral (maxBound :: Word64) = putSum (0 :: Word64) (fromIntegral size)
| otherwise = sizeError "encode" size
where
size = unTagged (sumSize :: Tagged (a :+: b) Word64)
- gget | GETSUM(Word8) | GETSUM(Word16) | GETSUM(Word32) | GETSUM(Word64)
+ gget | (GETSUMsize -Word8) <=) fromIntegral| GETSUM(Word16maxBound) | GETSUM::(Word8Word32))=|(getGETSUM::(GetWord64) ) >>= checkGetSum (fromIntegral size) | (size - 1) <= fromIntegral (maxBound :: Word16) = (get :: Get Word16) >>= checkGetSum (fromIntegral size) | (size - 1) <= fromIntegral (maxBound :: Word32) = (get :: Get Word32) >>= checkGetSum (fromIntegral size) | (size - 1) <= fromIntegral (maxBound :: Word64) = (get :: Get Word64) >>= checkGetSum (fromIntegral size)
| otherwise = sizeError "decode" size
where
size = unTagged (sumSize :: Tagged (a :+: b) Word64)
diff --git a/Cabal/Distribution/Compat/ReadP.hs b/Cabal/Distribution/Compat/ReadP.hs
index 3a50838..0218ee5 100644
--- a/Cabal/Distribution/Compat/ReadP.hs
+++ b/Cabal/Distribution/Compat/ReadP.hs
@@ -96,11 +96,11 @@ instance Functor (P s) where
fmap = liftM
instance Applicative (P s) where
- pure = return
+ pure x = Result x Fail
(<*>) = ap
instance Monad (P s) where
- return x = Result x Fail
+ return = pure
(Get f) >>= k = Get (\c -> f c >>= k)
(Look f) >>= k = Look (\s -> f s >>= k)
@@ -155,11 +155,11 @@ instance Functor (Parser r s) where
fmap h (R f) = R (\k -> f (k . h))
instance Applicative (Parser r s) where
- pure = return
+ pure x = R (\k -> k x)
(<*>) = ap
instance Monad (Parser r s) where
- return x = R (\k -> k x)
+ return = pure
fail _ = R (\_ -> Fail)
R m >>= f = R (\k -> m (\a -> let R m' = f a in m' k))
diff --git a/Cabal/Distribution/PackageDescription.hs b/Cabal/Distribution/PackageDescription.hs
index 17e10c1..f87a38c 100644
--- a/Cabal/Distribution/PackageDescription.hs
+++ b/Cabal/Distribution/PackageDescription.hs
@@ -1205,11 +1205,11 @@ instance Traversable Condition where
f `traverse` CAnd c d = CAnd `fmap` traverse f c <*> traverse f d
instance Applicative Condition where
- pure = return
+ pure = Var
(<*>) = ap
instance Monad Condition where
- return = Var
+ return = pure
-- Terminating cases
(>>=) (Lit x) _ = Lit x
(>>=) (Var x) f = f x
diff --git a/Cabal/Distribution/PackageDescription/Parse.hs b/Cabal/Distribution/PackageDescription/Parse.hs
index d32548c..3de06ce 100644
--- a/Cabal/Distribution/PackageDescription/Parse.hs
+++ b/Cabal/Distribution/PackageDescription/Parse.hs
@@ -640,12 +643,12 @@ instance (Monad m) => Applicative (StT s m) where
#else
instance (Monad m, Functor m) => Applicative (StT s m) where
#endif
- pure = return
+ pure a = StT (\s -> return (a,s))
(<*>) = ap
instance Monad m => Monad (StT s m) where
- return a = StT (\s -> return (a,s))
+ return = pure
StT f >>= g = StT $ \s -> do
(a,s') <- f s
runStT (g a) s'
@@ -1067,7 +1070,7 @@ parsePackageDescription file = do
-- Put these through the normal parsing pass too, so that we
-- collect the ModRenamings
let depFlds = filter isConstraint simplFlds
-
+
mapM_
(\(Section l n _ _) -> lift . warning $
"Unexpected section '" ++ n ++ "' on line " ++ show l)
diff --git a/Cabal/Distribution/PackageDescription/PrettyPrint.hs b/Cabal/Distribution/PackageDescription/PrettyPrint.hs
index bca9cc3..d4439cf 100644
--- a/Cabal/Distribution/PackageDescription/PrettyPrint.hs
+++ b/Cabal/Distribution/PackageDescription/PrettyPrint.hs
@@ -236,7 +236,7 @@ ppIf' :: a -> (a -> Maybe a -> Doc)
-> Condition ConfVar
-> CondTree ConfVar [Dependency] a
-> Doc
-ppIf' it ppIt c thenTree =
+ppIf' it ppIt c thenTree =
if isEmpty thenDoc
then mempty
else ppIfCondition c $$ nest indentWith thenDoc
diff --git a/Cabal/Distribution/ParseUtils.hs b/Cabal/Distribution/ParseUtils.hs
index 62011f4..0c4c8c1 100644
--- a/Cabal/Distribution/ParseUtils.hs
+++ b/Cabal/Distribution/ParseUtils.hs
@@ -98,12 +98,12 @@ instance Functor ParseResult where
fmap f (ParseOk ws x) = ParseOk ws $ f x
instance Applicative ParseResult where
- pure = return
+ pure = ParseOk []
(<*>) = ap
instance Monad ParseResult where
- return = ParseOk []
+ return = pure
ParseFailed err >>= _ = ParseFailed err
ParseOk ws x >>= f = case f x of
ParseFailed err -> ParseFailed err
diff --git a/Cabal/Distribution/Simple/BuildTarget.hs b/Cabal/Distribution/Simple/BuildTarget.hs
index 821a1d2..466a41c 100644
--- a/Cabal/Distribution/Simple/BuildTarget.hs
+++ b/Cabal/Distribution/Simple/BuildTarget.hs
@@ -798,11 +798,11 @@ instance Functor Match where
fmap f (InexactMatch d xs) = InexactMatch d (fmap f xs)
instance Applicative Match where
- pure = return
+ pure a = ExactMatch 0 [a]
(<*>) = ap
instance Monad Match where
- return a = ExactMatch 0 [a]
+ return = pure
NoMatch d ms >>= _ = NoMatch d ms
ExactMatch d xs >>= f = addDepth d
$ foldr matchPlus matchZero (map f xs)
diff --git a/Cabal/Distribution/Simple/Command.hs b/Cabal/Distribution/Simple/Command.hs
index a038de5..97c4430 100644
--- a/Cabal/Distribution/Simple/Command.hs
+++ b/Cabal/Distribution/Simple/Command.hs
@@ -592,7 +592,7 @@ noExtraFlags extraFlags =
-- | Helper function for creating globalCommand description
getNormalCommandDescriptions :: [Command action] -> [(String, String)]
-getNormalCommandDescriptions cmds =
+getNormalCommandDescriptions cmds =
[ (name, description)
| Command name description _ NormalCommand <- cmds ]
diff --git a/Cabal/Distribution/Simple/GHC.hs b/Cabal/Distribution/Simple/GHC.hs
index 4e466dc..11dd27c 100644
--- a/Cabal/Distribution/Simple/GHC.hs
+++ b/Cabal/Distribution/Simple/GHC.hs
@@ -874,7 +874,7 @@ buildOrReplExe forRepl verbosity numJobs _pkg_descr lbi
odir = fromFlag (ghcOptObjDir opts)
createDirectoryIfMissingVerbose verbosity True odir
needsRecomp <- checkNeedsRecompilation filename opts
- when needsRecomp $
+ when needsRecomp $
runGhcProg opts
| filename <- cSrcs ]
@@ -925,12 +925,12 @@ getRPaths lbi clbi | supportRPaths hostOS = do
-- E.g. when this comment was written, the *BSD operating systems were
-- untested with regards to Cabal RPATH handling, and were hence set to
-- 'False', while those operating systems themselves do support RPATH.
- supportRPaths Linux   = True
+ supportRPaths Linux = True
supportRPaths Windows = False
- supportRPaths OSX   = True
- supportRPaths FreeBSD   = False
- supportRPaths OpenBSD   = False
- supportRPaths NetBSD   = False
+ supportRPaths OSX = True
+ supportRPaths FreeBSD = False
+ supportRPaths OpenBSD = False
+ supportRPaths NetBSD = False
supportRPaths DragonFly = False
supportRPaths Solaris = False
supportRPaths AIX = False
diff --git a/Cabal/Distribution/Simple/UHC.hs b/Cabal/Distribution/Simple/UHC.hs
index f59a691..cfd7319 100644
--- a/Cabal/Distribution/Simple/UHC.hs
+++ b/Cabal/Distribution/Simple/UHC.hs
@@ -177,7 +177,7 @@ buildLib verbosity pkg_descr lbi lib clbi = do
(map display (libModules lib))
runUhcProg uhcArgs
-
+
return ()
buildExe :: Verbosity -> PackageDescription -> LocalBuildInfo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment