packages feed

adjunctions 0.2.2 → 0.3

raw patch · 2 files changed

+52/−1 lines, 2 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Control.Monad.Contra: ContraT :: g (w (f a)) -> ContraT f g w a
+ Control.Monad.Contra: contra :: Contravariant g => g (f a) -> Contra f g a
+ Control.Monad.Contra: instance (Adjunction f g, Comonad w) => Applicative (ContraT f g w)
+ Control.Monad.Contra: instance (Adjunction f g, Comonad w) => Monad (ContraT f g w)
+ Control.Monad.Contra: instance (Adjunction f g, Functor w) => Functor (ContraT f g w)
+ Control.Monad.Contra: newtype ContraT f g w a
+ Control.Monad.Contra: runContra :: Contravariant g => Contra f g a -> g (f a)
+ Control.Monad.Contra: runContraT :: ContraT f g w a -> g (w (f a))
+ Control.Monad.Contra: type Contra f g = ContraT f g Identity

Files

+ Control/Monad/Contra.hs view
@@ -0,0 +1,50 @@+{-# LANGUAGE MultiParamTypeClasses #-}+-----------------------------------------------------------------------------+-- |+-- Module      :  Control.Monad.Contra+-- Copyright   :  (C) 2011 Edward Kmett+-- License     :  BSD-style (see the file LICENSE)+--+-- Maintainer  :  Edward Kmett <ekmett@gmail.com>+-- Stability   :  provisional+-- Portability :  MPTCs, fundeps+--+-- Use a contravariant adjunction to Hask^op to build a 'Comonad' to +-- 'Monad' transformer.+----------------------------------------------------------------------------++module Control.Monad.Contra+  ( Contra+  , runContra+  , contra+  , ContraT(..)+  ) where++import Prelude hiding (sequence)+import Control.Applicative+import Control.Comonad+import Control.Monad (ap)+import Data.Functor.Identity+import Data.Functor.Contravariant+import Data.Functor.Contravariant.Adjunction++type Contra f g = ContraT f g Identity++newtype ContraT f g w a = ContraT { runContraT :: g (w (f a)) }++contra :: Contravariant g => g (f a) -> Contra f g a+contra = ContraT . contramap runIdentity++runContra :: Contravariant g => Contra f g a -> g (f a)+runContra = contramap Identity . runContraT++instance (Adjunction f g, Functor w) => Functor (ContraT f g w) where+  fmap f (ContraT g) = ContraT $ contramap (fmap (contramap f)) g+  +instance (Adjunction f g, Comonad w) => Applicative (ContraT f g w) where+  pure = ContraT . leftAdjunct extract+  (<*>) = ap++instance (Adjunction f g, Comonad w) => Monad (ContraT f g w) where+  return = ContraT . leftAdjunct extract+  ContraT m >>= f = ContraT $ contramap (extend (rightAdjunct (runContraT . f))) m
adjunctions.cabal view
@@ -1,6 +1,6 @@ name:          adjunctions category:      Data Structures, Adjunctions-version:       0.2.2+version:       0.3 license:       BSD3 cabal-version: >= 1.6 license-file:  LICENSE@@ -26,6 +26,7 @@     transformers >= 0.2.0 && < 0.3    exposed-modules:+    Control.Monad.Contra     Control.Monad.Trans.Adjoint     Control.Comonad.Trans.Adjoint     Data.Functor.Adjunction