Skip to content

Commit

Permalink
Contravariant Proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
ekmett committed Feb 5, 2013
1 parent f15a450 commit a5e4556
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
4 changes: 4 additions & 0 deletions Data/Functor/Contravariant.hs
Expand Up @@ -42,6 +42,7 @@ import Data.Functor.Product
import Data.Functor.Constant import Data.Functor.Constant
import Data.Functor.Compose import Data.Functor.Compose
import Data.Functor.Reverse import Data.Functor.Reverse
import Data.Proxy
import Prelude hiding ((.),id) import Prelude hiding ((.),id)


-- | Any instance should be subject to the following laws: -- | Any instance should be subject to the following laws:
Expand Down Expand Up @@ -87,6 +88,9 @@ instance Contravariant f => Contravariant (Reverse f) where
contramap f = Reverse . contramap f . getReverse contramap f = Reverse . contramap f . getReverse
{-# INLINE contramap #-} {-# INLINE contramap #-}


instance Contravariant Proxy where
contramap _ Proxy = Proxy

newtype Predicate a = Predicate { getPredicate :: a -> Bool } newtype Predicate a = Predicate { getPredicate :: a -> Bool }


-- | A 'Predicate' is a 'Contravariant' 'Functor', because 'contramap' can -- | A 'Predicate' is a 'Contravariant' 'Functor', because 'contramap' can
Expand Down
9 changes: 5 additions & 4 deletions contravariant.cabal
@@ -1,6 +1,6 @@
name: contravariant name: contravariant
category: Control, Data category: Control, Data
version: 0.3 version: 0.4
license: BSD3 license: BSD3
cabal-version: >= 1.6 cabal-version: >= 1.6
license-file: LICENSE license-file: LICENSE
Expand All @@ -23,9 +23,10 @@ source-repository head


library library
build-depends: build-depends:
base < 5, base < 5,
transformers >= 0.2 && < 0.4, tagged >= 0.4.4 && < 1,
transformers-compat >= 0.1 && < 1 transformers >= 0.2 && < 0.4,
transformers-compat >= 0.1 && < 1
exposed-modules: exposed-modules:
Data.Functor.Contravariant Data.Functor.Contravariant
Data.Functor.Contravariant.Compose Data.Functor.Contravariant.Compose
Expand Down

0 comments on commit a5e4556

Please sign in to comment.