constraint 0.1.0.0 → 0.1.0.1
raw patch · 3 files changed
+22/−3 lines, 3 files
Files
- Data/Constraint.hs +7/−1
- Data/Constraint/Compose.hs +11/−0
- constraint.cabal +4/−2
Data/Constraint.hs view
@@ -1,10 +1,13 @@-module Data.Constraint where+module Data.Constraint (Constraint, Dict (..), withDict, (:-) (..), (\\), unmapDict) where import Prelude hiding (Functor, (.), id) import Control.Categorical.Functor import Control.Category+import Data.Semigroup +import GHC.Exts (Constraint)+ data Dict a where Dict :: a => Dict a deriving instance Eq (Dict a)@@ -36,6 +39,9 @@ Sub c . Sub b = Sub (withDict b c) instance Functor (:-) (->) Dict where map (Sub a) Dict = withDict a Dict++(\\) :: (b => c) -> (a :- b) -> (a => c)+f \\ Sub Dict = f unmapDict :: (Dict a -> Dict b) -> a :- b unmapDict f = Sub (f Dict)
+ Data/Constraint/Compose.hs view
@@ -0,0 +1,11 @@+{-# LANGUAGE UndecidableSuperClasses #-}++module Data.Constraint.Compose (Compose, decompose) where++import Data.Constraint++class c (f a) => Compose (c :: β -> Constraint) (f :: α -> β) (a :: α)+instance c (f a) => Compose c f a++decompose :: Compose c f a :- c (f a)+decompose = Sub Dict
constraint.cabal view
@@ -1,5 +1,5 @@ name: constraint-version: 0.1.0.0+version: 0.1.0.1 synopsis: Reified constraints -- description: license: BSD3@@ -13,9 +13,10 @@ library exposed-modules: Data.Constraint+ , Data.Constraint.Compose -- other-modules: -- other-extensions: - build-depends: base >=4.10 && <4.12+ build-depends: base >=4.10 && <5 , category >=0.1.2 -- hs-source-dirs: default-language: Haskell2010@@ -24,5 +25,6 @@ , PolyKinds , ConstraintKinds , MultiParamTypeClasses+ , FlexibleInstances , GADTs , StandaloneDeriving