Permalink
Browse files

more aggressive inlining

  • Loading branch information...
1 parent f926a17 commit 7a22fb4519c7d7436ecdf926648844e890d79d3a @ekmett committed Nov 25, 2012
Showing with 10 additions and 1 deletion.
  1. +9 −0 Control/Comonad.hs
  2. +1 −1 comonad.cabal
View
@@ -116,29 +116,38 @@ class Functor w => Comonad w where
instance Comonad ((,)e) where
duplicate p = (fst p, p)
+ {-# INLINE duplicate #-}
extract = snd
+ {-# INLINE extract #-}
instance Monoid m => Comonad ((->)m) where
duplicate f m = f . mappend m
+ {-# INLINE duplicate #-}
extract f = f mempty
+ {-# INLINE extract #-}
instance Comonad Identity where
duplicate = Identity
+ {-# INLINE duplicate #-}
extract = runIdentity
+ {-# INLINE extract #-}
instance Comonad w => Comonad (IdentityT w) where
extend f (IdentityT m) = IdentityT (extend (f . IdentityT) m)
extract = extract . runIdentityT
+ {-# INLINE extract #-}
instance Comonad Tree where
duplicate w@(Node _ as) = Node w (map duplicate as)
extract (Node a _) = a
+ {-# INLINE extract #-}
instance Comonad NonEmpty where
extend f w@ ~(_ :| aas) = f w :| case aas of
[] -> []
(a:as) -> toList (extend f (a :| as))
extract ~(a :| _) = a
+ {-# INLINE extract #-}
-- | A @ComonadApply w@ is a strong lax symmetric semi-monoidal comonad on the
-- category @Hask@ of Haskell types.
View
@@ -1,6 +1,6 @@
name: comonad
category: Control, Comonads
-version: 3.0.0.2
+version: 3.0.1
license: BSD3
cabal-version: >= 1.6
license-file: LICENSE

0 comments on commit 7a22fb4

Please sign in to comment.