diff options
author | Ian Lynagh <ian@well-typed.com> | 2013-07-27 15:47:53 +0100 |
---|---|---|
committer | Ian Lynagh <ian@well-typed.com> | 2013-07-27 15:49:54 +0100 |
commit | 385055c0bdb05743b572b20caec9333a202ef88c (patch) | |
tree | b2901bb4b537bce2523b6fff9d85a42b5f8310c7 /compiler | |
parent | fb520bb6fe266f5581e2ce78e4c4f02619f0392b (diff) | |
download | haskell-385055c0bdb05743b572b20caec9333a202ef88c.tar.gz |
Beautify a few Binary instances
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/iface/IfaceSyn.lhs | 19 | ||||
-rw-r--r-- | compiler/main/Annotations.hs | 5 |
2 files changed, 13 insertions, 11 deletions
diff --git a/compiler/iface/IfaceSyn.lhs b/compiler/iface/IfaceSyn.lhs index 0150d216b2..7eb3d3a119 100644 --- a/compiler/iface/IfaceSyn.lhs +++ b/compiler/iface/IfaceSyn.lhs @@ -56,6 +56,7 @@ import TysWiredIn ( eqTyConName ) import Fingerprint import Binary +import Control.Monad import System.IO.Unsafe infixl 3 &&& @@ -312,10 +313,10 @@ instance Binary IfaceConDecls where get bh = do h <- getByte bh case h of - 0 -> get bh >>= (return . IfAbstractTyCon) + 0 -> liftM IfAbstractTyCon $ get bh 1 -> return IfDataFamTyCon - 2 -> get bh >>= (return . IfDataTyCon) - _ -> get bh >>= (return . IfNewTyCon) + 2 -> liftM IfDataTyCon $ get bh + _ -> liftM IfNewTyCon $ get bh visibleIfConDecls :: IfaceConDecls -> [IfaceConDecl] visibleIfConDecls (IfAbstractTyCon {}) = [] @@ -512,7 +513,7 @@ instance Binary IfaceIdInfo where h <- getByte bh case h of 0 -> return NoInfo - _ -> lazyGet bh >>= (return . HasInfo) -- NB lazyGet + _ -> liftM HasInfo $ lazyGet bh -- NB lazyGet -- Here's a tricky case: -- * Compile with -O module A, and B which imports A.f @@ -541,12 +542,12 @@ instance Binary IfaceInfoItem where get bh = do h <- getByte bh case h of - 0 -> get bh >>= (return . HsArity) - 1 -> get bh >>= (return . HsStrictness) + 0 -> liftM HsArity $ get bh + 1 -> liftM HsStrictness $ get bh 2 -> do lb <- get bh ad <- get bh return (HsUnfold lb ad) - 3 -> get bh >>= (return . HsInline) + 3 -> liftM HsInline $ get bh _ -> return HsNoCafRefs -- NB: Specialisations and rules come in separately and are @@ -777,8 +778,8 @@ instance Binary IfaceConAlt where h <- getByte bh case h of 0 -> return IfaceDefault - 1 -> get bh >>= (return . IfaceDataAlt) - _ -> get bh >>= (return . IfaceLitAlt) + 1 -> liftM IfaceDataAlt $ get bh + _ -> liftM IfaceLitAlt $ get bh data IfaceBinding = IfaceNonRec IfaceLetBndr IfaceExpr diff --git a/compiler/main/Annotations.hs b/compiler/main/Annotations.hs index ec179d86e2..7de1a9914b 100644 --- a/compiler/main/Annotations.hs +++ b/compiler/main/Annotations.hs @@ -24,6 +24,7 @@ import Serialized import UniqFM import Unique +import Control.Monad import Data.Maybe import Data.Typeable import Data.Word ( Word8 ) @@ -75,8 +76,8 @@ instance Binary name => Binary (AnnTarget name) where get bh = do h <- getByte bh case h of - 0 -> get bh >>= (return . NamedTarget) - _ -> get bh >>= (return . ModuleTarget) + 0 -> liftM NamedTarget $ get bh + _ -> liftM ModuleTarget $ get bh instance Outputable Annotation where ppr ann = ppr (ann_target ann) |