Commit 03ce005c authored by Steffen Michels's avatar Steffen Michels

implemented Monoid operations as macros

parent 556af199
Pipeline #8077 failed with stage
in 1 minute and 46 seconds
......@@ -2,15 +2,19 @@ definition module Data.Monoid
from StdOverloaded import class +, class *, class zero, class one
from Data.Maybe import :: Maybe
import qualified StdList
class Semigroup a where
mappend :: !a a -> a
mappend :: !a a -> a
mconcat :: !.[a] -> a
mconcat xs :== 'StdList'.foldr mappend mempty xs
class Monoid a | Semigroup a where
mempty :: a
mempty :: a
mconcat :: !.[a] -> a | Monoid a
(<++>) infixr 6 :: a a -> a | Semigroup a
(<++>) infixr 6 :: a a -> a
(<++>) ma mb :== mappend ma mb
instance Semigroup [a]
instance Semigroup (a -> b) | Semigroup b
......
......@@ -4,13 +4,7 @@ from StdOverloaded import class + (..), class * (..), class zero (..), class one
from StdBool import &&, ||
from StdFunc import o, id
from Data.Maybe import :: Maybe(..)
from StdList import ++, foldr
mconcat :: !.[a] -> a | Monoid a
mconcat xs = foldr mappend mempty xs
(<++>) infixr 6 :: a a -> a | Semigroup a
(<++>) ma mb = mappend ma mb
from StdList import ++
instance Semigroup [a] where
mappend xs ys = xs ++ ys
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment