Endo型
code:hs
-- Endo :: (a -> a) -> Endo a
newtype Endo a = Endo { appEndo :: a -> a }
code:ts
type Endo<T> = (x: T) => T;
instance
code:hs
instance Semigroup a => Semigroup (Endo a) where
Endo f <> Endo g = Endo (f . g)
code:hs
instance Monoid (Endo a) where
mempty = Endo id