valuations 0.0.5 → 0.0.6
raw patch · 8 files changed
+365/−74 lines, 8 filesdep +unordered-containers
Dependencies added: unordered-containers
Files
- changelog.md +14/−0
- examples/Data/Valuation/Example/PresheafExample.hs +68/−0
- examples/Data/Valuation/PresheafExample.hs +0/−68
- src/Data/Valuation.hs +2/−2
- src/Data/Valuation/CovariantFunctor.hs +175/−0
- src/Data/Valuation/Presheaf.hs +13/−2
- src/Data/Valuation/Semigroup.hs +90/−0
- valuations.cabal +3/−2
changelog.md view
@@ -1,3 +1,17 @@+0.0.6++* Add `opPresheaf` — `Presheaf'` value for `Op` from `Data.Functor.Contravariant`+* Add 16 new `CovariantFunctor'` values for standard `Functor` instances:+ `Either e`, `NonEmpty`, `(,) a`, `(->) r`, `Down`, `Dual`, `Sum`, `Product`,+ `First`, `Last`, `Min`, `Max`, `Map k`, `IntMap`, `Seq`, `Tree`+* Add `intersectionSet` — `Semigroup'` on `Set` via `Data.Set.intersection`+* Add `intersectionIntSet` — `Semigroup'` on `IntSet` via `Data.IntSet.intersection`+* Add `unionHashSet` and `intersectionHashSet` — `Semigroup'` on `HashSet` via+ `Data.HashSet.union` and `Data.HashSet.intersection`+* Export and document previously internal `Semigroup` values for `Set`, `IntSet`,+ and `HashSet`+* Add `unordered-containers` dependency+ 0.0.5 * Include example of usage of `Presheaf`
+ examples/Data/Valuation/Example/PresheafExample.hs view
@@ -0,0 +1,68 @@+{-# LANGUAGE DataKinds #-}+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE GADTs #-}+{-# LANGUAGE KindSignatures #-}+{-# LANGUAGE RankNTypes #-}+{-# OPTIONS_GHC -Wall -Werror #-}++-- | Take the category with 2 objects 1 and 2 and one arrow between then 1 -> 2 .+--+-- This is equivalent to the poset 1 <= 2 .+--+-- Take a presheaf that sends 2 to the set of strings {\"cat\"} and 1 to the set of strings {\"animal\", \"vegetable\"} .+--+-- The restriction function is defined so that \"cat\" | 1 = \"animal\" .+--+-- How can we define this in haskell?+module Data.Valuation.Example.PresheafExample where++import Data.Kind (Type)+import Data.Semigroupoid (Semigroupoid (..))+import Data.Valuation.Presheaf (Presheaf (..), runPresheaf)++-- Objects of the category+data Obj = One | Two deriving (Eq, Show)++-- Morphisms (finite category)+data Cat :: Obj -> Obj -> Type where+ Id1 :: Cat 'One 'One+ Id2 :: Cat 'Two 'Two+ OneToTwo :: Cat 'One 'Two++instance Semigroupoid Cat where+ Id1 `o` Id1 = Id1+ Id2 `o` Id2 = Id2+ OneToTwo `o` Id1 = OneToTwo+ Id2 `o` OneToTwo = OneToTwo++-- Values associated with each object+data OneVal = Animal | Vegetable deriving (Eq, Show)++data TwoVal = Cat deriving (Eq, Show)++-- GADT for the presheaf object mapping+data F :: Obj -> Type where+ FOne :: OneVal -> F 'One+ FTwo :: TwoVal -> F 'Two++-- Example presheaf+presheafExample :: Presheaf Cat (->) F+presheafExample = Presheaf go+ where+ go :: Cat a b -> F b -> F a+ -- identities+ go Id1 x = x+ go Id2 x = x+ -- restriction along One -> Two+ go OneToTwo (FTwo Cat) = FOne Animal++-- Add Show instance for F+instance Show (F 'One) where+ show (FOne x) = show x++instance Show (F 'Two) where+ show (FTwo x) = show x++-- Example usage+example :: F 'One+example = runPresheaf presheafExample OneToTwo (FTwo Cat)
− examples/Data/Valuation/PresheafExample.hs
@@ -1,68 +0,0 @@-{-# LANGUAGE DataKinds #-}-{-# LANGUAGE FlexibleInstances #-}-{-# LANGUAGE GADTs #-}-{-# LANGUAGE KindSignatures #-}-{-# LANGUAGE RankNTypes #-}-{-# OPTIONS_GHC -Wall -Werror #-}---- | Take the category with 2 objects 1 and 2 and one arrow between then 1 -> 2 .------ This is equivalent to the poset 1 <= 2 .------ Take a presheaf that sends 2 to the set of strings {\"cat\"} and 1 to the set of strings {\"animal\", \"vegetable\"} .------ The restriction function is defined so that \"cat\" | 1 = \"animal\" .------ How can we define this in haskell?-module Data.Valuation.PresheafExample where--import Data.Kind (Type)-import Data.Semigroupoid (Semigroupoid (..))-import Data.Valuation.Presheaf (Presheaf (..), runPresheaf)---- Objects of the category-data Obj = One | Two deriving (Eq, Show)---- Morphisms (finite category)-data Cat :: Obj -> Obj -> Type where- Id1 :: Cat 'One 'One- Id2 :: Cat 'Two 'Two- OneToTwo :: Cat 'One 'Two--instance Semigroupoid Cat where- Id1 `o` Id1 = Id1- Id2 `o` Id2 = Id2- OneToTwo `o` Id1 = OneToTwo- Id2 `o` OneToTwo = OneToTwo---- Values associated with each object-data OneVal = Animal | Vegetable deriving (Eq, Show)--data TwoVal = Cat deriving (Eq, Show)---- GADT for the presheaf object mapping-data F :: Obj -> Type where- FOne :: OneVal -> F 'One- FTwo :: TwoVal -> F 'Two---- Example presheaf-presheafExample :: Presheaf Cat (->) F-presheafExample = Presheaf go- where- go :: Cat a b -> F b -> F a- -- identities- go Id1 x = x- go Id2 x = x- -- restriction along One -> Two- go OneToTwo (FTwo Cat) = FOne Animal---- Add Show instance for F-instance Show (F 'One) where- show (FOne x) = show x--instance Show (F 'Two) where- show (FTwo x) = show x---- Example usage-example :: F 'One-example = runPresheaf presheafExample OneToTwo (FTwo Cat)
src/Data/Valuation.hs view
@@ -115,7 +115,7 @@ -- -- === Presheaf ----- A reified presheaf: 'Presheaf' @cat f cat'@ wraps @forall a b. cat a b -> cat' (f b) (f a)@, representing a contravariant mapping from a source category @cat@ to a target category @cat'@ acting on a type constructor @f@. When both categories are @(->)@, this specialises to 'Presheaf'' @f@ wrapping @forall a b. (a -> b) -> f b -> f a@, which is exactly 'Data.Functor.Contravariant.contramap'. Unlike 'Data.Functor.Contravariant.Contravariant' which is a type class (one instance per type), this is a value — and it is generalised over the source and target categories. Values are provided for standard types ('Data.Functor.Contravariant.Predicate', 'Data.Functor.Contravariant.Comparison', 'Data.Functor.Contravariant.Equivalence', 'Data.Proxy.Proxy', @'Data.Functor.Const.Const' r@). For a worked example of defining a 'Presheaf' over a finite category, see "Data.Valuation.PresheafExample".+-- A reified presheaf: 'Presheaf' @cat f cat'@ wraps @forall a b. cat a b -> cat' (f b) (f a)@, representing a contravariant mapping from a source category @cat@ to a target category @cat'@ acting on a type constructor @f@. When both categories are @(->)@, this specialises to 'Presheaf'' @f@ wrapping @forall a b. (a -> b) -> f b -> f a@, which is exactly 'Data.Functor.Contravariant.contramap'. Unlike 'Data.Functor.Contravariant.Contravariant' which is a type class (one instance per type), this is a value — and it is generalised over the source and target categories. Values are provided for standard types ('Data.Functor.Contravariant.Predicate', 'Data.Functor.Contravariant.Comparison', 'Data.Functor.Contravariant.Equivalence', 'Data.Proxy.Proxy', @'Data.Functor.Const.Const' r@). For a worked example of defining a 'Presheaf' over a finite category, see "Data.Valuation.Example.PresheafExample". -- -- === CovariantFunctor --@@ -204,7 +204,7 @@ -- * "Data.Valuation.Valuation" — Domain-information pairs -- * "Data.Valuation.ValuationAlgebra" — Full algebra with unit and zero -- * "Data.Valuation.ValuationAlgebraOp" — Operations on valuation algebras (@set var -> v@)--- * "Data.Valuation.PresheafExample" — Worked example: a presheaf over a finite category+-- * "Data.Valuation.Example.PresheafExample" — Worked example: a presheaf over a finite category module Data.Valuation ( module V, )
src/Data/Valuation/CovariantFunctor.hs view
@@ -29,9 +29,25 @@ -- * covariant functor values identityCovariantFunctor, maybeCovariantFunctor,+ eitherCovariantFunctor, listCovariantFunctor,+ nonEmptyCovariantFunctor,+ pairCovariantFunctor,+ readerCovariantFunctor,+ downCovariantFunctor,+ dualCovariantFunctor,+ sumCovariantFunctor,+ productCovariantFunctor,+ firstCovariantFunctor,+ lastCovariantFunctor,+ minCovariantFunctor,+ maxCovariantFunctor, proxyCovariantFunctor, constCovariantFunctor,+ mapCovariantFunctor,+ intMapCovariantFunctor,+ seqCovariantFunctor,+ treeCovariantFunctor, -- * laws lawCovariantFunctorIdentity,@@ -42,14 +58,26 @@ import Data.Functor.Compose (Compose (..)) import Data.Functor.Const (Const (..)) import Data.Functor.Identity (Identity (..))+import Data.IntMap (IntMap)+import Data.List.NonEmpty (NonEmpty)+import Data.Map (Map)+import Data.Monoid (Dual, First, Last, Product, Sum)+import Data.Ord (Down) import Data.Profunctor (Profunctor (dimap)) import Data.Proxy (Proxy)+import Data.Semigroup (Max, Min)+import Data.Sequence (Seq)+import Data.Tree (Tree) -- $setup -- >>> :set -Wno-name-shadowing -Wno-type-defaults -- >>> import Data.Functor.Const (Const(..)) -- >>> import Data.Functor.Identity (Identity(..))+-- >>> import Data.List.NonEmpty (NonEmpty(..))+-- >>> import Data.Monoid (Dual(..), Sum(..), Product(..), First(..), Last(..))+-- >>> import Data.Ord (Down(..)) -- >>> import Data.Proxy (Proxy(..))+-- >>> import Data.Semigroup (Min(..), Max(..)) -- | -- >>> runCovariantFunctor listCovariantFunctor (+1) [1,2,3]@@ -136,6 +164,16 @@ maybeCovariantFunctor :: CovariantFunctor' Maybe maybeCovariantFunctor = CovariantFunctor fmap +-- | 'CovariantFunctor'' on @'Either' e@: maps over the 'Right' value,+-- leaving 'Left' unchanged.+--+-- >>> runCovariantFunctor eitherCovariantFunctor (+1) (Right 3 :: Either String Int)+-- Right 4+-- >>> runCovariantFunctor eitherCovariantFunctor (+1) (Left "error" :: Either String Int)+-- Left "error"+eitherCovariantFunctor :: CovariantFunctor' (Either e)+eitherCovariantFunctor = CovariantFunctor fmap+ -- | 'CovariantFunctor'' on @[]@: maps over each element. -- -- >>> runCovariantFunctor listCovariantFunctor (+1) [1,2,3]@@ -148,6 +186,105 @@ listCovariantFunctor :: CovariantFunctor' [] listCovariantFunctor = CovariantFunctor fmap +-- | 'CovariantFunctor'' on 'NonEmpty': maps over each element.+--+-- >>> runCovariantFunctor nonEmptyCovariantFunctor (+1) (1 :| [2,3])+-- 2 :| [3,4]+-- >>> runCovariantFunctor nonEmptyCovariantFunctor show (42 :| [])+-- "42" :| []+nonEmptyCovariantFunctor :: CovariantFunctor' NonEmpty+nonEmptyCovariantFunctor = CovariantFunctor fmap++-- | 'CovariantFunctor'' on @(,) a@: maps over the second component of a pair.+--+-- >>> runCovariantFunctor pairCovariantFunctor (+1) ("hello", 3)+-- ("hello",4)+-- >>> runCovariantFunctor pairCovariantFunctor show (True, 42)+-- (True,"42")+pairCovariantFunctor :: CovariantFunctor' ((,) a)+pairCovariantFunctor = CovariantFunctor fmap++-- | 'CovariantFunctor'' on @(->) r@: post-composes a function.+--+-- >>> runCovariantFunctor readerCovariantFunctor (*2) (+1) 3+-- 8+-- >>> runCovariantFunctor readerCovariantFunctor show ((+1) :: Int -> Int) 3+-- "4"+readerCovariantFunctor :: CovariantFunctor' ((->) r)+readerCovariantFunctor = CovariantFunctor fmap++-- | 'CovariantFunctor'' on 'Down': maps over the wrapped value.+--+-- >>> runCovariantFunctor downCovariantFunctor (+1) (Down 3)+-- Down 4+-- >>> runCovariantFunctor downCovariantFunctor show (Down 42)+-- Down "42"+downCovariantFunctor :: CovariantFunctor' Down+downCovariantFunctor = CovariantFunctor fmap++-- | 'CovariantFunctor'' on 'Dual': maps over the wrapped value.+--+-- >>> runCovariantFunctor dualCovariantFunctor (+1) (Dual 3)+-- Dual {getDual = 4}+-- >>> runCovariantFunctor dualCovariantFunctor show (Dual 42)+-- Dual {getDual = "42"}+dualCovariantFunctor :: CovariantFunctor' Dual+dualCovariantFunctor = CovariantFunctor fmap++-- | 'CovariantFunctor'' on @'Data.Monoid.Sum'@: maps over the wrapped value.+--+-- >>> runCovariantFunctor sumCovariantFunctor (+1) (Sum 3)+-- Sum {getSum = 4}+-- >>> runCovariantFunctor sumCovariantFunctor show (Sum 42)+-- Sum {getSum = "42"}+sumCovariantFunctor :: CovariantFunctor' Sum+sumCovariantFunctor = CovariantFunctor fmap++-- | 'CovariantFunctor'' on @'Data.Monoid.Product'@: maps over the wrapped value.+--+-- >>> runCovariantFunctor productCovariantFunctor (+1) (Product 3)+-- Product {getProduct = 4}+-- >>> runCovariantFunctor productCovariantFunctor show (Product 42)+-- Product {getProduct = "42"}+productCovariantFunctor :: CovariantFunctor' Product+productCovariantFunctor = CovariantFunctor fmap++-- | 'CovariantFunctor'' on @'Data.Monoid.First'@: maps over the wrapped 'Maybe' value.+--+-- >>> runCovariantFunctor firstCovariantFunctor (+1) (First (Just 3))+-- First {getFirst = Just 4}+-- >>> runCovariantFunctor firstCovariantFunctor (+1) (First Nothing)+-- First {getFirst = Nothing}+firstCovariantFunctor :: CovariantFunctor' First+firstCovariantFunctor = CovariantFunctor fmap++-- | 'CovariantFunctor'' on @'Data.Monoid.Last'@: maps over the wrapped 'Maybe' value.+--+-- >>> runCovariantFunctor lastCovariantFunctor (+1) (Last (Just 3))+-- Last {getLast = Just 4}+-- >>> runCovariantFunctor lastCovariantFunctor (+1) (Last Nothing)+-- Last {getLast = Nothing}+lastCovariantFunctor :: CovariantFunctor' Last+lastCovariantFunctor = CovariantFunctor fmap++-- | 'CovariantFunctor'' on 'Min': maps over the wrapped value.+--+-- >>> runCovariantFunctor minCovariantFunctor (+1) (Min 3)+-- Min {getMin = 4}+-- >>> runCovariantFunctor minCovariantFunctor show (Min 42)+-- Min {getMin = "42"}+minCovariantFunctor :: CovariantFunctor' Min+minCovariantFunctor = CovariantFunctor fmap++-- | 'CovariantFunctor'' on 'Max': maps over the wrapped value.+--+-- >>> runCovariantFunctor maxCovariantFunctor (+1) (Max 3)+-- Max {getMax = 4}+-- >>> runCovariantFunctor maxCovariantFunctor show (Max 42)+-- Max {getMax = "42"}+maxCovariantFunctor :: CovariantFunctor' Max+maxCovariantFunctor = CovariantFunctor fmap+ -- | 'CovariantFunctor'' on 'Proxy': trivially maps the phantom type parameter. -- -- >>> runCovariantFunctor proxyCovariantFunctor not (Proxy :: Proxy Bool)@@ -168,6 +305,44 @@ -- Const "hello" constCovariantFunctor :: CovariantFunctor' (Const r) constCovariantFunctor = CovariantFunctor fmap++-- | 'CovariantFunctor'' on @'Map' k@: maps over the values, preserving keys.+--+-- >>> import qualified Data.Map as Map+-- >>> runCovariantFunctor mapCovariantFunctor (+1) (Map.fromList [("a", 1), ("b", 2)])+-- fromList [("a",2),("b",3)]+-- >>> runCovariantFunctor mapCovariantFunctor show (Map.fromList [(1, True)])+-- fromList [(1,"True")]+mapCovariantFunctor :: CovariantFunctor' (Map k)+mapCovariantFunctor = CovariantFunctor fmap++-- | 'CovariantFunctor'' on 'IntMap': maps over the values, preserving keys.+--+-- >>> import qualified Data.IntMap as IntMap+-- >>> runCovariantFunctor intMapCovariantFunctor (+1) (IntMap.fromList [(1, 10), (2, 20)])+-- fromList [(1,11),(2,21)]+-- >>> runCovariantFunctor intMapCovariantFunctor show (IntMap.fromList [(1, True)])+-- fromList [(1,"True")]+intMapCovariantFunctor :: CovariantFunctor' IntMap+intMapCovariantFunctor = CovariantFunctor fmap++-- | 'CovariantFunctor'' on 'Seq': maps over each element.+--+-- >>> import qualified Data.Sequence as Seq+-- >>> runCovariantFunctor seqCovariantFunctor (+1) (Seq.fromList [1,2,3])+-- fromList [2,3,4]+-- >>> runCovariantFunctor seqCovariantFunctor show (Seq.fromList [1,2])+-- fromList ["1","2"]+seqCovariantFunctor :: CovariantFunctor' Seq+seqCovariantFunctor = CovariantFunctor fmap++-- | 'CovariantFunctor'' on 'Tree': maps over every node label.+--+-- >>> import Data.Tree (Tree(..))+-- >>> runCovariantFunctor treeCovariantFunctor (+1) (Node 1 [Node 2 [], Node 3 []])+-- Node {rootLabel = 2, subForest = [Node {rootLabel = 3, subForest = []},Node {rootLabel = 4, subForest = []}]}+treeCovariantFunctor :: CovariantFunctor' Tree+treeCovariantFunctor = CovariantFunctor fmap -- | The identity law for a 'CovariantFunctor'': mapping the identity morphism -- must be the identity on @f a@.
src/Data/Valuation/Presheaf.hs view
@@ -21,7 +21,7 @@ -- @ -- -- For a worked example of defining a 'Presheaf' over a finite category,--- see "Data.Valuation.PresheafExample".+-- see "Data.Valuation.Example.PresheafExample". module Data.Valuation.Presheaf ( Presheaf (..), Presheaf',@@ -37,6 +37,7 @@ predicatePresheaf, comparisonPresheaf, equivalencePresheaf,+ opPresheaf, proxyPresheaf, constPresheaf, @@ -52,6 +53,7 @@ ( Comparison (..), Contravariant (contramap), Equivalence (..),+ Op (..), Predicate (..), ) import Data.Profunctor (Profunctor (dimap))@@ -60,7 +62,7 @@ -- $setup -- >>> :set -Wno-name-shadowing -Wno-type-defaults--- >>> import Data.Functor.Contravariant (Predicate(..), getPredicate, Comparison(..), getComparison, Equivalence(..), getEquivalence)+-- >>> import Data.Functor.Contravariant (Predicate(..), getPredicate, Comparison(..), getComparison, Equivalence(..), getEquivalence, Op(..), getOp) -- >>> import Data.Functor.Const (Const(..)) -- >>> import Data.Proxy (Proxy(..)) @@ -222,6 +224,15 @@ -- True equivalencePresheaf :: Presheaf' Equivalence equivalencePresheaf = Presheaf contramap++-- | 'Presheaf'' on 'Op': pulls back an 'Op' along a function.+--+-- >>> getOp (runPresheaf opPresheaf (+1) (Op negate :: Op Int Int)) 3+-- -4+-- >>> getOp (runPresheaf opPresheaf show (Op length :: Op Int String)) 42+-- 2+opPresheaf :: Presheaf' (Op r)+opPresheaf = Presheaf contramap -- | 'Presheaf'' on 'Proxy': trivially maps the phantom type parameter. --
src/Data/Valuation/Semigroup.hs view
@@ -80,7 +80,11 @@ productF, composeF, unionSet,+ intersectionSet, unionIntSet,+ intersectionIntSet,+ unionHashSet,+ intersectionHashSet, -- * laws lawAssociative,@@ -121,6 +125,8 @@ import Data.Proxy (Proxy (..)) import Data.Set (Set) import qualified Data.Set as Set+import Data.HashSet (HashSet)+import qualified Data.HashSet as HashSet import Data.Tuple (Solo) import Data.Void (Void, absurd) import GHC.Conc (STM)@@ -706,6 +712,26 @@ unionSet :: (Ord a) => Semigroup' (Set a) unionSet = review applySemigroup Set.union +-- | Semigroup on 'Set' via 'Data.Set.intersection'.+--+-- >>> import qualified Data.Set as Set+-- >>> runSemigroup intersectionSet (Set.fromList [1,2,3]) (Set.fromList [2,3,4]) :: Set Int+-- fromList [2,3]+--+-- >>> import qualified Data.Set as Set+-- >>> runSemigroup intersectionSet (Set.fromList [1,2]) (Set.fromList [3,4]) :: Set Int+-- fromList []+--+-- >>> import qualified Data.Set as Set+-- >>> runSemigroup intersectionSet (Set.fromList [1,2,3]) (Set.fromList [1,2,3]) :: Set Int+-- fromList [1,2,3]+--+-- >>> import qualified Data.Set as Set+-- >>> lawAssociative intersectionSet (Set.fromList [1,2,3]) (Set.fromList [2,3,4]) (Set.fromList [3,4,5 :: Int])+-- True+intersectionSet :: (Ord a) => Semigroup' (Set a)+intersectionSet = review applySemigroup Set.intersection+ -- | Semigroup on 'IntSet' via 'Data.IntSet.union'. -- -- >>> import qualified Data.IntSet as IntSet@@ -729,3 +755,67 @@ -- True unionIntSet :: Semigroup' IntSet unionIntSet = review applySemigroup IntSet.union++-- | Semigroup on 'IntSet' via 'Data.IntSet.intersection'.+--+-- >>> import qualified Data.IntSet as IntSet+-- >>> runSemigroup intersectionIntSet (IntSet.fromList [1,2,3]) (IntSet.fromList [2,3,4])+-- fromList [2,3]+--+-- >>> import qualified Data.IntSet as IntSet+-- >>> runSemigroup intersectionIntSet (IntSet.fromList [1,2]) (IntSet.fromList [3,4])+-- fromList []+--+-- >>> import qualified Data.IntSet as IntSet+-- >>> runSemigroup intersectionIntSet (IntSet.fromList [1,2,3]) (IntSet.fromList [1,2,3])+-- fromList [1,2,3]+--+-- >>> import qualified Data.IntSet as IntSet+-- >>> lawAssociative intersectionIntSet (IntSet.fromList [1,2,3]) (IntSet.fromList [2,3,4]) (IntSet.fromList [3,4,5])+-- True+intersectionIntSet :: Semigroup' IntSet+intersectionIntSet = review applySemigroup IntSet.intersection++-- | Semigroup on 'HashSet' via 'Data.HashSet.union'.+--+-- >>> import qualified Data.HashSet as HashSet+-- >>> runSemigroup unionHashSet (HashSet.fromList [1,2]) (HashSet.fromList [2,3]) :: HashSet Int+-- fromList [1,2,3]+--+-- >>> import qualified Data.HashSet as HashSet+-- >>> runSemigroup unionHashSet (HashSet.fromList [1,2,3]) HashSet.empty :: HashSet Int+-- fromList [1,2,3]+--+-- >>> import qualified Data.HashSet as HashSet+-- >>> runSemigroup unionHashSet HashSet.empty (HashSet.fromList [4,5]) :: HashSet Int+-- fromList [4,5]+--+-- >>> import qualified Data.HashSet as HashSet+-- >>> runSemigroup unionHashSet (HashSet.fromList [1,2]) (HashSet.fromList [1,2]) :: HashSet Int+-- fromList [1,2]+--+-- >>> import qualified Data.HashSet as HashSet+-- >>> lawAssociative unionHashSet (HashSet.fromList [1,2]) (HashSet.fromList [2,3]) (HashSet.fromList [3,4 :: Int])+-- True+unionHashSet :: Eq a => Semigroup' (HashSet a)+unionHashSet = review applySemigroup HashSet.union++-- | Semigroup on 'HashSet' via 'Data.HashSet.intersection'.+--+-- >>> import qualified Data.HashSet as HashSet+-- >>> runSemigroup intersectionHashSet (HashSet.fromList [1,2,3]) (HashSet.fromList [2,3,4]) :: HashSet Int+-- fromList [2,3]+--+-- >>> import qualified Data.HashSet as HashSet+-- >>> runSemigroup intersectionHashSet (HashSet.fromList [1,2]) (HashSet.fromList [3,4]) :: HashSet Int+-- fromList []+--+-- >>> import qualified Data.HashSet as HashSet+-- >>> runSemigroup intersectionHashSet (HashSet.fromList [1,2,3]) (HashSet.fromList [1,2,3]) :: HashSet Int+-- fromList [1,2,3]+--+-- >>> import qualified Data.HashSet as HashSet+-- >>> lawAssociative intersectionHashSet (HashSet.fromList [1,2,3]) (HashSet.fromList [2,3,4]) (HashSet.fromList [3,4,5 :: Int])+-- True+intersectionHashSet :: Eq a => Semigroup' (HashSet a)+intersectionHashSet = review applySemigroup HashSet.intersection
valuations.cabal view
@@ -1,6 +1,6 @@ cabal-version: 2.4 name: valuations-version: 0.0.5+version: 0.0.6 synopsis: Valuations description: Valuations: Valuation and Valuation Algebra license: BSD-3-Clause@@ -35,7 +35,7 @@ Data.Valuation.ValuationAlgebra Data.Valuation.ValuationAlgebraOp - Data.Valuation.PresheafExample+ Data.Valuation.Example.PresheafExample build-depends: base >= 4.8 && < 6 , adjunctions >= 4.4 && < 5@@ -49,6 +49,7 @@ , profunctors >= 5 && < 6 , selective >= 0.7.0.1 && < 1 , semigroupoids >= 5.2 && < 7+ , unordered-containers >= 0.2 && < 1 , witherable >= 0.4 && < 1 hs-source-dirs: src