{-# LANGUAGE CPP #-}
#if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ >= 702
#if __GLASGOW_HASKELL__ >= 707 && (MIN_VERSION_comonad(3,0,3))
{-# LANGUAGE Safe #-}
#else
{-# LANGUAGE Trustworthy #-}
#endif
#endif
------------------------------------------------------------------------------- |-- Module : Data.Semigroupoid-- Copyright : (C) 2007-2011 Edward Kmett-- License : BSD-style (see the file LICENSE)---- Maintainer : Edward Kmett <ekmett@gmail.com>-- Stability : provisional-- Portability : portable---- A semigroupoid satisfies all of the requirements to be a Category except-- for the existence of identity arrows.----------------------------------------------------------------------------
module Data.Semigroupoid
( Semigroupoid(..)
, WrappedCategory(..)
, Semi(..)
) where
import Control.Arrow
import Data.Functor.Bind
import Data.Functor.Extend
import Data.Functor.Contravariant
import Control.Comonad
import Data.Semigroup
import Control.Category
import Prelude hiding (id, (.))
-- | 'Control.Category.Category' sans 'Control.Category.id'
class Semigroupoidc where
o :: cjk -> cij -> cik
instance Semigroupoid(->) where
o = (.)-- | <http://en.wikipedia.org/wiki/Band_(mathematics)#Rectangular_bands>
instance Semigroupoid(,) where
o (_,k) (i,_) = (i,k)
instance Bind m =>Semigroupoid (Kleislim) where
Kleislig`o`Kleislif = Kleisli$ \a -> fa>>-g
instance Extend w =>Semigroupoid (Cokleisliw) where
Cokleislif`o`Cokleislig = Cokleisli$f.extendedg
instance SemigroupoidOp where
Opf`o`Opg = Op (g`o`f)
newtype WrappedCategorykab = WrapCategory { unwrapCategory :: kab }
instance Category k =>Semigroupoid (WrappedCategoryk) where
WrapCategoryf`o`WrapCategoryg = WrapCategory (f.g)
instance Category k =>Category (WrappedCategoryk) where
id = WrapCategoryidWrapCategoryf.WrapCategoryg = WrapCategory (f.g)
newtype Semimab = Semi { getSemi :: m }
instance Semigroup m =>Semigroupoid (Semim) where
Semim`o`Semin = Semi (m<>n)
instance Monoid m =>Category (Semim) where
id = SemimemptySemim.Semin = Semi (m`mappend`n)