git.iko.soy/typeable/refined-containers
on main help sign in
Add Functor.Classes instances and Bifoldable
commit65e29772f719381c93fd10955545c05f1d6ca476 authormniip <mniip@mniip.com> dateMon 24 Feb 2025, 14:58 (2 years ago) parent405a23a
3 files changed+26−1
src/Data/HashMap/Common/Refined.hs+6−1 src/Data/IntMap/Common/Refined.hs+6 src/Data/Map/Common/Refined.hs+14
src/Data/HashMap/Common/Refined.hs+6−1
@@ -4,6 +4,7 @@ module Data.HashMap.Common.Refined where
44
55import Control.Monad.Reader
66import Control.DeepSeq
7+import Data.Bifoldable
78import Data.Coerce
89import Data.Constraint (Dict(..))
910import Data.Container.Refined.Hashable
@@ -11,6 +12,7 @@ import Data.Container.Refined.Proofs
1112import Data.Container.Refined.Unsafe
1213import Data.Distributive
1314import Data.Foldable.WithIndex
15+import Data.Functor.Classes
1416import Data.Functor.Rep
1517import Data.Functor.WithIndex
1618import qualified Data.Hashable as Hashable
@@ -44,7 +46,10 @@ import Data.Monoid (All(..))
4446-- always derive @'KnownHashSet' s k@ by pattern matching on the 'Dict' returned
4547-- by 'keysSet'.
4648newtype HashMap s k a = HashMap (HashMap.HashMap k a)
47− deriving newtype (Eq, Ord, Show, Functor, Foldable, Hashable.Hashable, NFData)
49+ deriving newtype
50+ ( Eq, Eq1, Eq2, Ord, Ord1, Ord2, Show, Show1, Show2
51+ , Functor, Foldable, Bifoldable, Hashable.Hashable, NFData
52+ )
4853 deriving stock (Traversable)
4954type role HashMap nominal nominal representational
5055
src/Data/IntMap/Common/Refined.hs+6
@@ -36,6 +36,9 @@ import qualified Data.IntMap.Strict as IntMapStrict
3636import qualified Data.List as List
3737#endif
3838
39+#if MIN_VERSION_containers(0, 5, 9) || MIN_VERSION_hashable(1, 4, 0)
40+import Data.Functor.Classes
41+#endif
3942
4043-- | A wrapper around a regular 'Data.IntMap.IntMap' with a type parameter @s@
4144-- identifying the set of keys present in the map.
@@ -51,6 +54,9 @@ newtype IntMap s a = IntMap (IntMap.IntMap a)
5154 deriving newtype (Eq, Ord, Show, Functor, Foldable, NFData)
5255#if MIN_VERSION_hashable(1, 3, 4)
5356 deriving newtype (Hashable.Hashable)
57+#endif
58+#if MIN_VERSION_containers(0, 5, 9) || MIN_VERSION_hashable(1, 4, 0)
59+ deriving newtype (Eq1, Ord1, Show1)
5460#endif
5561 deriving stock (Traversable)
5662type role IntMap nominal representational
src/Data/Map/Common/Refined.hs+14
@@ -23,6 +23,10 @@ import Refined
2323import Refined.Unsafe
2424import Unsafe.Coerce
2525
26+#if MIN_VERSION_containers(0, 6, 3)
27+import Data.Bifoldable
28+#endif
29+
2630#if MIN_VERSION_containers(0, 6, 2)
2731#elif MIN_VERSION_containers(0, 5, 8)
2832import Data.Functor.Const (Const(..))
@@ -33,6 +37,10 @@ import qualified Data.List as List
3337import qualified Data.Map.Strict as MapStrict
3438#endif
3539
40+#if MIN_VERSION_containers(0, 5, 9) || MIN_VERSION_hashable(1, 4, 0)
41+import Data.Functor.Classes
42+#endif
43+
3644
3745-- | A wrapper around a regular 'Data.Map.Map' with a type parameter @s@
3846-- identifying the set of keys present in the map.
@@ -49,6 +57,12 @@ newtype Map s k a = Map (Map.Map k a)
4957 deriving newtype (Eq, Ord, Show, Functor, Foldable, NFData)
5058#if MIN_VERSION_hashable(1, 3, 4)
5159 deriving newtype (Hashable.Hashable)
60+#endif
61+#if MIN_VERSION_containers(0, 6, 3)
62+ deriving newtype (Bifoldable)
63+#endif
64+#if MIN_VERSION_containers(0, 5, 9) || MIN_VERSION_hashable(1, 4, 0)
65+ deriving newtype (Eq1, Eq2, Ord1, Ord2, Show1, Show2)
5266#endif
5367 deriving stock (Traversable)
5468type role Map nominal nominal representational