Lift restrictions on base version and abandon Semigroup instance
This commit is contained in:
parent
c481ea4981
commit
a34e1e8806
2 changed files with 3 additions and 5 deletions
|
@ -21,6 +21,6 @@ library
|
||||||
exposed-modules: Stream
|
exposed-modules: Stream
|
||||||
-- other-modules:
|
-- other-modules:
|
||||||
-- other-extensions:
|
-- other-extensions:
|
||||||
build-depends: base >=4.12 && <4.13
|
build-depends: base >=4.9 && <4.13
|
||||||
hs-source-dirs: src
|
hs-source-dirs: src
|
||||||
default-language: Haskell2010
|
default-language: Haskell2010
|
||||||
|
|
|
@ -6,12 +6,10 @@ import Data.List (intercalate)
|
||||||
|
|
||||||
data Stream a = Stream [(a, Stream a)] deriving Show
|
data Stream a = Stream [(a, Stream a)] deriving Show
|
||||||
|
|
||||||
instance Semigroup (Stream a) where
|
|
||||||
(<>) (Stream []) b = b
|
|
||||||
(<>) (Stream pairs) b = Stream $ (\(a, stream) -> (a, stream <> b)) <$> pairs
|
|
||||||
|
|
||||||
instance Monoid (Stream a) where
|
instance Monoid (Stream a) where
|
||||||
mempty = fromList []
|
mempty = fromList []
|
||||||
|
mappend (Stream []) b = b
|
||||||
|
mappend (Stream pairs) b = Stream $ (\(a, stream) -> (a, stream `mappend` b)) <$> pairs
|
||||||
|
|
||||||
fromList :: [a] -> Stream a
|
fromList :: [a] -> Stream a
|
||||||
fromList [] = Stream []
|
fromList [] = Stream []
|
||||||
|
|
Loading…
Reference in a new issue