git.iko.soy/typeable/attoparsec
on master help sign in
Mark a few more definitions as inlined.

The benefit here is a little dubious, since I see a tiny performance gain.

commit448c5d70e466f282c7d9f382b6077d494607c4a6 authorBryan O'Sullivan <bos@serpentine.com> dateWed 11 May 2011, 09:48 (15 years ago) parent4a3f7ae
2 files changed+12
Data/Attoparsec/Internal/Types.hs+8 Data/Attoparsec/Zepto.hs+4
Data/Attoparsec/Internal/Types.hs+8
@@ -67,6 +67,7 @@ fmapR f (Done bs r) = Done bs (f r)
6767
6868instance Functor Result where
6969 fmap = fmapR
70+ {-# INLINE fmap #-}
7071
7172newtype Input = I {unI :: B.ByteString}
7273newtype Added = A {unA :: B.ByteString}
@@ -139,6 +140,7 @@ fmapP p m = Parser $ \i0 a0 m0 f k ->
139140
140141instance Functor Parser where
141142 fmap = fmapP
143+ {-# INLINE fmap #-}
142144
143145apP :: Parser (a -> b) -> Parser a -> Parser b
144146apP d e = do
@@ -149,23 +151,29 @@ apP d e = do
149151
150152instance Applicative Parser where
151153 pure = returnP
154+ {-# INLINE pure #-}
152155 (<*>) = apP
156+ {-# INLINE (<*>) #-}
153157
154158 -- These definitions are equal to the defaults, but this
155159 -- way the optimizer doesn't have to work so hard to figure
156160 -- that out.
157161 (*>) = (>>)
162+ {-# INLINE (*>) #-}
158163 x <* y = x >>= \a -> y >> return a
164+ {-# INLINE (<*) #-}
159165
160166instance Monoid (Parser a) where
161167 mempty = failDesc "mempty"
162168 {-# INLINE mempty #-}
163169 mappend = plus
170+ {-# INLINE mappend #-}
164171
165172instance Alternative Parser where
166173 empty = failDesc "empty"
167174 {-# INLINE empty #-}
168175 (<|>) = plus
176+ {-# INLINE (<|>) #-}
169177
170178failDesc :: String -> Parser a
171179failDesc err = Parser (\i0 a0 m0 kf _ks -> kf i0 a0 m0 [] msg)
Data/Attoparsec/Zepto.hs+4
@@ -86,7 +86,9 @@ instance MonadPlus Parser where
8686
8787instance Applicative Parser where
8888 pure = return
89+ {-# INLINE pure #-}
8990 (<*>) = ap
91+ {-# INLINE (<*>) #-}
9092
9193gets :: (S -> a) -> Parser a
9294gets f = Parser $ \s -> (# OK (f s), s #)
@@ -106,11 +108,13 @@ instance Monoid (Parser a) where
106108 mempty = fail "mempty"
107109 {-# INLINE mempty #-}
108110 mappend = mplus
111+ {-# INLINE mappend #-}
109112
110113instance Alternative Parser where
111114 empty = fail "empty"
112115 {-# INLINE empty #-}
113116 (<|>) = mplus
117+ {-# INLINE (<|>) #-}
114118
115119-- | Consume input while the predicate returns 'True'.
116120takeWhile :: (Word8 -> Bool) -> Parser ByteString