Commit 203fb604 authored by Camil Staps's avatar Camil Staps 🐧

Move Semigroup, Monoid of (a->b) to Data.Func

parent e0b784c1
......@@ -3,11 +3,15 @@ definition module Data.Func
from Data.Functor import class Functor
from Control.Applicative import class Applicative
from Control.Monad import class Monad
from Data.Monoid import class Semigroup, class Monoid
instance Functor ((->) r)
instance Applicative ((->) r)
instance Monad ((->) r)
instance Semigroup (a -> b) | Semigroup b
instance Monoid (a -> b) | Monoid b
/**
* Function application.
* @type (a -> b) a -> b
......
......@@ -2,6 +2,7 @@ implementation module Data.Func
from StdFunc import const, o
import Data.Functor
import Data.Monoid
import Control.Applicative
import Control.Monad
......@@ -18,6 +19,14 @@ instance Monad ((->) r)
where
bind ma a2mb = \r -> a2mb (ma r) r
instance Semigroup (a -> b) | Semigroup b
where
mappend f g = \x -> mappend (f x) (g x)
instance Monoid (a -> b) | Monoid b
where
mempty = \_ -> mempty
seqSt :: !(a .st -> .st) ![a] !.st -> .st
seqSt f [] st = st
seqSt f [x:xs] st = seqSt f xs (f x st)
......
......@@ -18,14 +18,12 @@ where
mconcat :: !.[a] -> a | Monoid a
mconcat xs :== 'StdList'.foldr mappend mempty xs
instance Semigroup (a -> b) | Semigroup b
instance Semigroup ()
instance Semigroup (a, b) | Semigroup a & Semigroup b
instance Semigroup (a, b, c) | Semigroup a & Semigroup b & Semigroup c
instance Semigroup (a, b, c, d) | Semigroup a & Semigroup b & Semigroup c & Semigroup d
instance Semigroup (a, b, c, d, e) | Semigroup a & Semigroup b & Semigroup c & Semigroup d & Semigroup e
instance Monoid (a -> b) | Monoid b
instance Monoid ()
instance Monoid (a, b) | Monoid a & Monoid b
instance Monoid (a, b, c) | Monoid a & Monoid b & Monoid c
......
......@@ -6,12 +6,6 @@ from StdFunc import o, id
from Data.Maybe import :: Maybe(..)
from StdList import ++
instance Semigroup (a -> b) | Semigroup b where
mappend f g = \x -> mappend (f x) (g x)
instance Monoid (a -> b) | Monoid b where
mempty = \_ -> mempty
instance Semigroup () where
mappend _ _ = ()
......
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