Skip to content

Commit 594c3c1

Browse files
authored
Merge pull request #33 from sergv/fix-build-with-7.10.3-and-doctests
Fix build with 7.10.3 and fix doctests
2 parents 6f3f313 + b99bae8 commit 594c3c1

5 files changed

Lines changed: 251 additions & 244 deletions

File tree

src/Data/Functor/Of.hs

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
{-# LANGUAGE CPP, DeriveDataTypeable, DeriveTraversable, DeriveFoldable,
22
DeriveGeneric #-}
3-
module Data.Functor.Of where
3+
module Data.Functor.Of (Of(..)) where
44
import Data.Monoid (Monoid (..))
55
import Data.Semigroup (Semigroup (..))
66
import Control.Applicative
77
import Data.Traversable (Traversable)
88
import Data.Foldable (Foldable)
9-
#if MIN_VERSION_base(4,8,0)
109
import Data.Bifunctor
11-
#endif
1210
import Data.Data
13-
import Data.Typeable
14-
import GHC.Generics (Generic, Generic1)
11+
#if MIN_VERSION_base(4,9,0)
1512
import Data.Functor.Classes
13+
import Data.Foldable (Foldable)
14+
import Data.Traversable (Traversable)
15+
#endif
16+
import GHC.Generics (Generic, Generic1)
1617

1718
-- | A left-strict pair; the base functor for streams of individual elements.
1819
data Of a b = !a :> b
@@ -35,7 +36,7 @@ instance (Monoid a, Monoid b) => Monoid (Of a b) where
3536
instance Functor (Of a) where
3637
fmap f (a :> x) = a :> f x
3738
{-#INLINE fmap #-}
38-
a <$ (b :> x) = b :> a
39+
a <$ (b :> _) = b :> a
3940
{-#INLINE (<$) #-}
4041

4142
#if MIN_VERSION_base(4,8,0)
@@ -51,40 +52,43 @@ instance Bifunctor Of where
5152
instance Monoid a => Applicative (Of a) where
5253
pure x = mempty :> x
5354
{-#INLINE pure #-}
54-
m :> f <*> m' :> x = mappend m m' :> f x
55+
(m :> f) <*> (m' :> x) = mappend m m' :> f x
5556
{-#INLINE (<*>) #-}
56-
m :> x *> m' :> y = mappend m m' :> y
57+
(m :> _) *> (m' :> y) = mappend m m' :> y
5758
{-#INLINE (*>) #-}
58-
m :> x <* m' :> y = mappend m m' :> x
59+
(m :> x) <* (m' :> _) = mappend m m' :> x
5960
{-#INLINE (<*) #-}
6061

6162
instance Monoid a => Monad (Of a) where
62-
return x = mempty :> x
63+
return = pure
6364
{-#INLINE return #-}
64-
m :> x >> m' :> y = mappend m m' :> y
65+
(m :> _) >> (m' :> y) = mappend m m' :> y
6566
{-#INLINE (>>) #-}
66-
m :> x >>= f = let m' :> y = f x in mappend m m' :> y
67+
(m :> x) >>= f = let m' :> y = f x in mappend m m' :> y
6768
{-#INLINE (>>=) #-}
6869

70+
#if MIN_VERSION_base(4,9,0)
6971
instance Show a => Show1 (Of a) where
7072
liftShowsPrec = liftShowsPrec2 showsPrec showList
7173

74+
instance Eq a => Eq1 (Of a) where
75+
liftEq = liftEq2 (==)
76+
77+
instance Ord a => Ord1 (Of a) where
78+
liftCompare = liftCompare2 compare
79+
7280
instance Show2 Of where
7381
liftShowsPrec2 spa _sla spb _slb p (a :> b) =
7482
showParen (p > 5) $
7583
spa 6 a .
7684
showString " :> " .
7785
spb 6 b
7886

79-
instance Eq a => Eq1 (Of a) where
80-
liftEq = liftEq2 (==)
81-
82-
instance Ord a => Ord1 (Of a) where
83-
liftCompare = liftCompare2 compare
84-
8587
instance Eq2 Of where
86-
liftEq2 eq1 eq2 (x :> y) (z :> w) = eq1 x z && eq2 y w
88+
liftEq2 f g (x :> y) (z :> w) = f x z && g y w
8789

8890
instance Ord2 Of where
8991
liftCompare2 comp1 comp2 (x :> y) (z :> w) =
9092
comp1 x z `mappend` comp2 y w
93+
#endif
94+

src/Streaming.hs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{-# LANGUAGE RankNTypes #-}
22

3-
{-# OPTIONS_GHC -Wall #-}
43
module Streaming
54
(
65
-- * An iterable streaming monad transformer
@@ -115,10 +114,10 @@ import Data.Bifunctor
115114
Some of these are quite abstract and pervade any use of the library,
116115
e.g.
117116
118-
> maps :: (forall x . f x -> g x) -> Stream f m r -> Stream g m r
119-
> mapped :: (forall x . f x -> m (g x)) -> Stream f m r -> Stream g m r
120-
> hoist :: (forall x . m x -> n x) -> Stream f m r -> Stream f n r -- from the MFunctor instance
121-
> concats :: Stream (Stream f m) m r -> Stream f m r
117+
> maps :: (forall x . f x -> g x) -> Stream f m r -> Stream g m r
118+
> mapped :: (forall x . f x -> m (g x)) -> Stream f m r -> Stream g m r
119+
> hoist :: (forall x . m x -> n x) -> Stream f m r -> Stream f n r -- from the MFunctor instance
120+
> concats :: Stream (Stream f m) m r -> Stream f m r
122121
123122
(assuming here and thoughout that @m@ or @n@ satisfies a @Monad@ constraint, and
124123
@f@ or @g@ a @Functor@ constraint.)
@@ -128,9 +127,9 @@ import Data.Bifunctor
128127
> chunksOf :: Int -> Stream f m r -> Stream (Stream f m) m r
129128
> splitsAt :: Int -> Stream f m r -> Stream f m (Stream f m r)
130129
> zipsWith :: (forall x y. f x -> g y -> h (x, y))
131-
-> Stream f m r -> Stream g m r -> Stream h m r
130+
> -> Stream f m r -> Stream g m r -> Stream h m r
132131
> zipsWith' :: (forall x y p. (x -> y -> p) -> f x -> g y -> h p)
133-
-> Stream f m r -> Stream g m r -> Stream h m r
132+
> -> Stream f m r -> Stream g m r -> Stream h m r
134133
> intercalates :: Stream f m () -> Stream (Stream f m) m r -> Stream f m r
135134
> unzips :: Stream (Compose f g) m r -> Stream f (Stream g m) r
136135
> separate :: Stream (Sum f g) m r -> Stream f (Stream g) m r -- cp. partitionEithers

0 commit comments

Comments
 (0)