Lift restrictions on base version and abandon Semigroup instance

This commit is contained in:
Tissevert 2019-05-03 19:06:24 +02:00
parent c481ea4981
commit a34e1e8806
2 changed files with 3 additions and 5 deletions

View File

@ -21,6 +21,6 @@ library
exposed-modules: Stream
-- other-modules:
-- other-extensions:
build-depends: base >=4.12 && <4.13
build-depends: base >=4.9 && <4.13
hs-source-dirs: src
default-language: Haskell2010

View File

@ -6,12 +6,10 @@ import Data.List (intercalate)
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
mempty = fromList []
mappend (Stream []) b = b
mappend (Stream pairs) b = Stream $ (\(a, stream) -> (a, stream `mappend` b)) <$> pairs
fromList :: [a] -> Stream a
fromList [] = Stream []