Endo型
endomorphism
自己準同型
code:hs
-- Endo :: (a -> a) -> Endo a
newtype Endo a = Endo { appEndo :: a -> a }
code:ts
type Endo<T> = (x: T) => T;
instance
Semigroup型クラス
code:hs
instance Semigroup a => Semigroup (Endo a) where
Endo f <> Endo g = Endo (f . g)
Monoid型クラス
code:hs
instance Monoid (Endo a) where
mempty = Endo id
https://hackage.haskell.org/package/monoid-extras-0.6/docs/Data-Monoid-Endomorphism.html
https://haskell.e-bigmoon.com/posts/2019/02-04-endo-monoid.html
https://hackage.haskell.org/package/base-4.12.0.0/docs/Data-Monoid.html#t:Endo
https://speakerdeck.com/taiki45/haskell-detukuru-vm-san-riyuku-endomorphism