exists 0.1 → 0.2
raw patch · 7 files changed
+65/−25 lines, 7 filesdep −comonaddep −comonads-fddep −pointeddep ~contravariantPVP ok
version bump matches the API change (PVP)
Dependencies removed: comonad, comonads-fd, pointed
Dependency ranges changed: contravariant
API changes (from Hackage documentation)
- Data.Exists: instance Comonad (Exists1 (ComonadEnv e))
- Data.Exists: instance Comonad (Exists1 (ComonadStore s))
- Data.Exists: instance Comonad (Exists1 (ComonadTraced m))
- Data.Exists: instance Comonad (Exists1 Comonad)
- Data.Exists: instance ComonadEnv e (Exists1 (ComonadEnv e))
- Data.Exists: instance ComonadStore s (Exists1 (ComonadStore s))
- Data.Exists: instance ComonadTraced m (Exists1 (ComonadTraced m))
- Data.Exists: instance Copointed (Exists1 Copointed)
- Data.Exists: instance Extend (Exists1 (ComonadEnv e))
- Data.Exists: instance Extend (Exists1 (ComonadStore s))
- Data.Exists: instance Extend (Exists1 (ComonadTraced m))
- Data.Exists: instance Extend (Exists1 Comonad)
- Data.Exists: instance Extend (Exists1 Extend)
- Data.Exists: instance Functor (Exists1 (ComonadEnv e))
- Data.Exists: instance Functor (Exists1 (ComonadStore s))
- Data.Exists: instance Functor (Exists1 (ComonadTraced m))
- Data.Exists: instance Functor (Exists1 Comonad)
- Data.Exists: instance Functor (Exists1 Extend)
- Data.Exists.Defaults: askDefault :: ExistentialWith1 (ComonadEnv env) e => e a -> env
- Data.Exists.Defaults: copointDefault :: ExistentialWith1 Copointed e => e a -> a
- Data.Exists.Defaults: duplicateDefault :: ExistentialWith1 Extend e => e a -> e (e a)
- Data.Exists.Defaults: extractDefault :: ExistentialWith1 Comonad e => e a -> a
- Data.Exists.Defaults: peekDefault :: ExistentialWith1 (ComonadStore s) e => s -> e a -> a
- Data.Exists.Defaults: peeksDefault :: ExistentialWith1 (ComonadStore s) e => (s -> s) -> e a -> a
- Data.Exists.Defaults: posDefault :: ExistentialWith1 (ComonadStore s) e => e a -> s
- Data.Exists.Defaults: seekDefault :: ExistentialWith1 (ComonadStore s) e => s -> e a -> e a
- Data.Exists.Defaults: seeksDefault :: ExistentialWith1 (ComonadStore s) e => (s -> s) -> e a -> e a
- Data.Exists.Defaults: traceDefault :: ExistentialWith1 (ComonadTraced m) e => m -> e a -> a
+ Data.Exists.CPS: Exists :: (forall r. (forall a. c a => a -> r) -> r) -> Exists c
+ Data.Exists.CPS: Exists1 :: (forall r. (forall f. c f => f a -> r) -> r) -> Exists1 c a
+ Data.Exists.CPS: instance Existential (Exists c)
+ Data.Exists.CPS: instance Existential1 (Exists1 c)
+ Data.Exists.CPS: newtype Exists c
+ Data.Exists.CPS: newtype Exists1 c a
+ Data.Exists.CPS: withExists :: Exists c -> forall r. (forall a. c a => a -> r) -> r
+ Data.Exists.CPS: withExists1 :: Exists1 c a -> forall r. (forall f. c f => f a -> r) -> r
Files
- Control/Constraint/Combine.hs +1/−1
- Data/Exists.hs +7/−3
- Data/Exists/CPS.hs +23/−0
- Data/Exists/Defaults.hs +14/−10
- Data/Exists/Internal.hs +2/−2
- LICENSE +1/−1
- exists.cabal +17/−8
Control/Constraint/Combine.hs view
@@ -29,7 +29,7 @@ type c `And` d = c :&: d infixl 7 `And` --- | An empty constraint which implies nothing.+-- | An empty constraint, which implies nothing. -- -- @':&:'@ and @'Empty'@ form a type-level monoid with @'Empty'@ as the identity element. class Empty a
Data/Exists.hs view
@@ -1,7 +1,7 @@ {-# LANGUAGE TypeFamilies, ConstraintKinds, FlexibleInstances, MultiParamTypeClasses #-} {-# OPTIONS_GHC -fno-warn-orphans #-} --- | Existential datatypes holding evidence of constraints and type classes for existential datatypes.+-- | Existential datatypes holding evidence of constraints, and type classes for existential datatypes. module Data.Exists (module Data.Exists.Internal) where import Data.Exists.Internal@@ -11,7 +11,7 @@ import Unsafe.Coerce (unsafeCoerce) import qualified Data.Traversable as T (foldMapDefault, fmapDefault) import Data.Dynamic (toDyn, fromDyn)-import Control.Comonad (liftW)+--import Control.Comonad (liftW) import Control.Constraint.Combine (Empty) import Data.Typeable (Typeable) import Control.Exception (Exception)@@ -27,13 +27,14 @@ import Data.Foldable (Foldable (..)) import Data.Traversable (Traversable (..)) import Data.Functor.Contravariant (Contravariant (..))+{- import Data.Functor.Extend (Extend (..)) import Control.Comonad (Comonad (..)) import Control.Comonad.Env.Class (ComonadEnv (..)) import Control.Comonad.Traced.Class (ComonadTraced (..)) import Control.Comonad.Store.Class (ComonadStore (..)) import Data.Copointed (Copointed (..))-+-} -- | @'ConstraintOf' 'Any' = 'Empty'@ instance Existential Any where@@ -123,9 +124,11 @@ mapM = mapMDefault sequence = sequenceDefault + instance Contravariant (Exists1 Contravariant) where contramap = contramapDefault +{- instance Functor (Exists1 Extend) where fmap f = apply1 (exists1 . fmap f) @@ -183,3 +186,4 @@ instance Copointed (Exists1 Copointed) where copoint = copointDefault+-}
+ Data/Exists/CPS.hs view
@@ -0,0 +1,23 @@+{-# LANGUAGE ConstraintKinds, TypeFamilies, RankNTypes #-}++-- | CPS-transformed versions of @Exists@ and @Exists1@, provided for completeness and curiosity.++module Data.Exists.CPS(Exists(..), Exists1(..)) where++import Data.Exists.Internal(Existential(..), Existential1(..))++newtype Exists c = Exists { withExists :: forall r. (forall a. c a => a -> r) -> r }++-- | @'ConstraintOf' ('Exists' c) = c@+instance Existential (Exists c) where+ type ConstraintOf (Exists c) = c+ exists a = Exists $ \f -> f a+ apply f e = withExists e f++newtype Exists1 c a = Exists1 { withExists1 :: forall r. (forall f. c f => f a -> r) -> r }++-- | @'ConstraintOf1' ('Exists1' c) = c@+instance Existential1 (Exists1 c) where+ type ConstraintOf1 (Exists1 c) = c+ exists1 a = Exists1 $ \f -> f a+ apply1 f e = withExists1 e f
Data/Exists/Defaults.hs view
@@ -15,12 +15,14 @@ import Data.Foldable (Foldable (..)) import Data.Traversable (Traversable (..)) import Data.Functor.Contravariant (Contravariant (..))+{- import Data.Functor.Extend (Extend (..)) import Control.Comonad (Comonad (..)) import Control.Comonad.Env.Class (ComonadEnv (..)) import Control.Comonad.Traced.Class (ComonadTraced (..)) import Control.Comonad.Store.Class (ComonadStore (..)) import Data.Copointed (Copointed (..))+-} -- * Prelude.Show showDefault :: ExistentialWith Show e => e -> String@@ -69,6 +71,7 @@ contramapDefault :: ExistentialWith1 Contravariant e => (a -> b) -> e b -> e a contramapDefault f = apply1 (exists1 . contramap f) +{- -- * Data.Functor.Extend.Extend duplicateDefault :: ExistentialWith1 Extend e => e a -> e (e a) duplicateDefault = apply1 (exists1 . fmap exists1 . duplicate)@@ -107,6 +110,7 @@ -- * Data.Copointed.Copointed copointDefault :: ExistentialWith1 Copointed e => e a -> a copointDefault = apply1 copoint+-} {-# INLINE showDefault #-} {-# INLINE showsPrecDefault #-}@@ -122,14 +126,14 @@ {-# INLINE mapMDefault #-} {-# INLINE sequenceDefault #-} {-# INLINE contramapDefault #-}-{-# INLINE duplicateDefault #-}+{- INLINE duplicateDefault -} {- INLINE extendDefault -}-{-# INLINE extractDefault #-}-{-# INLINE askDefault #-}-{-# INLINE traceDefault #-}-{-# INLINE posDefault #-}-{-# INLINE peekDefault #-}-{-# INLINE peeksDefault #-}-{-# INLINE seekDefault #-}-{-# INLINE seeksDefault #-}-{-# INLINE copointDefault #-}+{- INLINE extractDefault -}+{- INLINE askDefault -}+{- INLINE traceDefault -}+{- INLINE posDefault -}+{- INLINE peekDefault -}+{- INLINE peeksDefault -}+{- INLINE seekDefault -}+{- INLINE seeksDefault -}+{- INLINE copointDefault -}
Data/Exists/Internal.hs view
@@ -43,7 +43,7 @@ -- -- > foo :: (Existential e, ConstraintOf e ~ Show) => e ----- GHC would have output an error message, because the instance of @'Existential'@ to use would have been ambiguous. (The @'apply' f '.' 'exists'@ problem is the same as the @'show' '.' 'read'@ problem.)+-- GHC would have given us an error message, because the instance of @'Existential'@ to use would have been ambiguous. (The @'apply' f . 'exists'@ problem is the same as the @'show' . 'read'@ problem.) class Existential e where type ConstraintOf e :: * -> Constraint -- | Construct 'e' from a value of a type satisfying the constraint.@@ -80,7 +80,7 @@ -- | A version of @'Existential'@ for kind @* -> *@. class Existential1 e where type ConstraintOf1 e :: (* -> *) -> Constraint- -- | Construct 'e' from a value of a type constructor applied to a type where the type constructor satisfies the constraint.+ -- | Construct 'e' from a value of a type constructor applied to a type, where the type constructor satisfies the constraint. exists1 :: (ConstraintOf1 e) f => f a -> e a -- | Apply a function requiring the constraint to the held value. apply1 :: (forall f. (ConstraintOf1 e) f => f a -> r) -> e a -> r
LICENSE view
@@ -1,4 +1,4 @@-Copyright 2011 Gábor Lehel+Copyright 2012 Gábor Lehel All rights reserved.
exists.cabal view
@@ -1,10 +1,10 @@ name: exists category: Constraints-version: 0.1+version: 0.2 author: Gábor Lehel maintainer: Gábor Lehel <illissius@gmail.com> homepage: http://github.com/glehel/exists-copyright: Copyright (C) 2011 Gábor Lehel+copyright: Copyright (C) 2012 Gábor Lehel license: BSD3 license-file: LICENSE stability: experimental@@ -24,9 +24,17 @@ . * A type-level combinator for combining constraint constructors. .- Some of these should maybe be split off into separate packages.+ (Some of these might be better off as separate packages.) .- "Data.Exists" is the important module, the rest are peripheral.+ "Data.Exists" has most of the important things.+ .+ Minimum GHC: 7.4+ .+ Changes in 0.2:+ .+ * Removed @Comonad@-related things (they were probably useless anyways)+ .+ * Added @Data.Exists.CPS@ source-repository head type: git@@ -50,6 +58,7 @@ exposed-modules: Data.Anything Data.Exists+ Data.Exists.CPS Data.Exists.Defaults Control.Constraint.Combine @@ -58,10 +67,10 @@ build-depends: base >= 4.5 && < 5,- contravariant == 0.1.*,- comonad == 1.1.*,- comonads-fd == 2.0.*,- pointed == 2.0.*+ contravariant >= 0.1 && < 0.3+-- comonad == 1.1.*,+-- comonads-fd == 2.0.*,+-- pointed == 2.0.* ghc-options: -Wall