-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Classes and data structures complementing the singletons library -- -- Please see README.md @package pringletons @version 0.4 module Data.Singletons.Class class EqSing1 f eqSing1 :: EqSing1 f => Sing a -> f a -> f a -> Bool class EqSing2 f eqSing2 :: EqSing2 f => Sing a -> Sing b -> f a b -> f a b -> Bool class EqSing1 f => OrdSing1 f compareSing1 :: OrdSing1 f => Sing a -> f a -> f a -> Ordering class EqSing2 f => OrdSing2 f compareSing2 :: OrdSing2 f => Sing a -> Sing b -> f a b -> f a b -> Ordering class ShowSing2 f showsPrecSing2 :: ShowSing2 f => Int -> Sing a -> Sing b -> f a b -> ShowS class ReadSing2 f readPrecSing2 :: ReadSing2 f => Sing a -> Sing b -> ReadPrec (f a b) class HashableSing1 f hashWithSaltSing1 :: HashableSing1 f => Sing a -> Int -> f a -> Int class HashableSing2 f hashWithSaltSing2 :: HashableSing2 f => Sing a -> Sing b -> Int -> f a b -> Int class ToJSONSing1 f toJSONSing1 :: ToJSONSing1 f => Sing a -> f a -> Value class ToJSONSing2 f toJSONSing2 :: ToJSONSing2 f => Sing a -> Sing b -> f a b -> Value class FromJSONSing1 f parseJSONSing1 :: FromJSONSing1 f => Sing a -> Value -> Parser (f a) class FromJSONSing2 f parseJSONSing2 :: FromJSONSing2 f => Sing a -> Sing b -> Value -> Parser (f a b) class ShowKind k where showsPrecKind i s xs = showsPrec i (fromSing s) xs showsPrecKind :: ShowKind k => Int -> Sing (x :: k) -> ShowS showsPrecKind :: (ShowKind k, SingKind k, Show (DemoteRep k)) => Int -> Sing (x :: k) -> ShowS class ReadKind k where readPrecKind = fmap toSing readPrec readPrecKind :: ReadKind k => ReadPrec (SomeSing k) readPrecKind :: (ReadKind k, SingKind k, Read (DemoteRep k)) => ReadPrec (SomeSing k) class HashableKind k where hashWithSaltKind i s = hashWithSalt i (fromSing s) hashWithSaltKind :: HashableKind k => Int -> Sing (x :: k) -> Int hashWithSaltKind :: (HashableKind k, SingKind k, Hashable (DemoteRep k)) => Int -> Sing (x :: k) -> Int class ToJSONKind k where toJSONKind s = String (pack (showKind s)) toJSONKind :: ToJSONKind k => Sing (x :: k) -> Value toJSONKind :: (ToJSONKind k, ShowKind k) => Sing (x :: k) -> Value class FromJSONKind k where parseJSONKind (String t) = let s = unpack t in case readMaybeKind s of { Nothing -> fail ("Could not parse singleton from: " ++ s) Just a -> return a } parseJSONKind :: FromJSONKind k => Value -> Parser (SomeSing k) parseJSONKind :: (FromJSONKind k, ReadKind k) => Value -> Parser (SomeSing k) class ToJSONKeyKind k where toJSONKeyKind s = pack (showKind s) toJSONKeyKind :: ToJSONKeyKind k => Sing (x :: k) -> Text toJSONKeyKind :: (ToJSONKeyKind k, ShowKind k) => Sing (x :: k) -> Text class FromJSONKeyKind k where parseJSONKeyKind t = let s = unpack t in case readMaybeKind s of { Nothing -> fail ("Could not parse key: " ++ s) Just a -> return a } parseJSONKeyKind :: FromJSONKeyKind k => Text -> Parser (SomeSing k) parseJSONKeyKind :: (FromJSONKeyKind k, ReadKind k) => Text -> Parser (SomeSing k) newtype Applied1 (f :: TyFun k Type -> Type) (a :: k) Applied1 :: Apply f a -> Applied1 [getApplied1] :: Applied1 -> Apply f a newtype Applied2 (f :: TyFun k (TyFun j Type -> Type) -> Type) (a :: k) (b :: j) Applied2 :: Apply (Apply f a) b -> Applied2 [getApplied2] :: Applied2 -> Apply (Apply f a) b newtype Applied3 (f :: TyFun k (TyFun j (TyFun l Type -> Type) -> Type) -> Type) (a :: k) (b :: j) (c :: l) Applied3 :: Apply (Apply (Apply f a) b) c -> Applied3 [getApplied3] :: Applied3 -> Apply (Apply (Apply f a) b) c data SomeSingWith1 (k :: Type) (f :: k -> Type) [SomeSingWith1] :: forall (a :: k) (f :: k -> Type). Sing a -> f a -> SomeSingWith1 k f data SomeSingWith2 (k :: Type) (j :: Type) (f :: k -> j -> Type) [SomeSingWith2] :: forall (a :: k) (b :: j) (f :: k -> j -> Type). Sing a -> Sing b -> f a b -> SomeSingWith2 k j f data SingWith1 k (f :: k -> Type) (a :: k) [SingWith1] :: Sing a -> f a -> SingWith1 k f a -- | This is a wrapper for SomeSing that provides common typeclass -- instances for it. This can be helpful when you want to use -- Data.Set with SomeSing. newtype ClassySomeSing kproxy ClassySomeSing :: SomeSing kproxy -> ClassySomeSing kproxy [getClassySomeSing] :: ClassySomeSing kproxy -> SomeSing kproxy class EqApplied1 (f :: TyFun k Type -> Type) eqApplied1 :: EqApplied1 f => proxy f -> Sing a -> Apply f a -> Apply f a -> Bool class HashableApplied1 (f :: TyFun k Type -> Type) hashWithSaltApplied1 :: HashableApplied1 f => proxy f -> Sing a -> Int -> Apply f a -> Int class ToJSONApplied1 (f :: TyFun k Type -> Type) toJSONApplied1 :: ToJSONApplied1 f => proxy f -> Sing a -> Apply f a -> Value class FromJSONApplied1 (f :: TyFun k Type -> Type) parseJSONApplied1 :: FromJSONApplied1 f => proxy f -> Sing a -> Value -> Parser (Apply f a) showKind :: forall (a :: k). ShowKind k => Sing a -> String readMaybeKind :: ReadKind kproxy => String -> Maybe (SomeSing kproxy) -- | Helper function to demote an equality check. It would be nice if this -- could be added as an Eq instance for SomeSing, but it -- would required collapsing a lot of the modules in singletons -- to prevent cyclic imports. Or it could be provided as an orphan -- instance. eqSome :: SEq kproxy => SomeSing kproxy -> SomeSing kproxy -> Bool -- | Helper function to demote a comparison compareSome :: SOrd kproxy => SomeSing kproxy -> SomeSing kproxy -> Ordering instance forall k (f :: k Data.Singletons.~> *) (a :: k). GHC.Classes.Eq (Data.Singletons.Apply f a) => GHC.Classes.Eq (Data.Singletons.Class.Applied1 f a) instance forall k (f :: k Data.Singletons.~> *) (a :: k). GHC.Classes.Ord (Data.Singletons.Apply f a) => GHC.Classes.Ord (Data.Singletons.Class.Applied1 f a) instance forall k (f :: k Data.Singletons.~> *) (a :: k). GHC.Read.Read (Data.Singletons.Apply f a) => GHC.Read.Read (Data.Singletons.Class.Applied1 f a) instance forall k (f :: k Data.Singletons.~> *) (a :: k). GHC.Show.Show (Data.Singletons.Apply f a) => GHC.Show.Show (Data.Singletons.Class.Applied1 f a) instance forall k (f :: k Data.Singletons.~> *) (a :: k). Data.Hashable.Class.Hashable (Data.Singletons.Apply f a) => Data.Hashable.Class.Hashable (Data.Singletons.Class.Applied1 f a) instance forall k (f :: k Data.Singletons.~> *) (a :: k). Data.Aeson.Types.ToJSON.ToJSON (Data.Singletons.Apply f a) => Data.Aeson.Types.ToJSON.ToJSON (Data.Singletons.Class.Applied1 f a) instance forall k (f :: k Data.Singletons.~> *) (a :: k). Data.Aeson.Types.FromJSON.FromJSON (Data.Singletons.Apply f a) => Data.Aeson.Types.FromJSON.FromJSON (Data.Singletons.Class.Applied1 f a) instance forall k (f :: Data.Singletons.TyFun k GHC.Types.Type -> GHC.Types.Type). Data.Singletons.Class.EqApplied1 f => Data.Singletons.Class.EqSing1 (Data.Singletons.Class.Applied1 f) instance forall k (f :: Data.Singletons.TyFun k GHC.Types.Type -> GHC.Types.Type). Data.Singletons.Class.ToJSONApplied1 f => Data.Singletons.Class.ToJSONSing1 (Data.Singletons.Class.Applied1 f) instance forall k (f :: Data.Singletons.TyFun k GHC.Types.Type -> GHC.Types.Type). Data.Singletons.Class.FromJSONApplied1 f => Data.Singletons.Class.FromJSONSing1 (Data.Singletons.Class.Applied1 f) instance forall k (f :: Data.Singletons.TyFun k GHC.Types.Type -> GHC.Types.Type). Data.Singletons.Class.HashableApplied1 f => Data.Singletons.Class.HashableSing1 (Data.Singletons.Class.Applied1 f) instance forall kproxy (f :: kproxy -> *). (Data.Singletons.Class.EqSing1 f, Data.Singletons.Decide.SDecide kproxy) => GHC.Classes.Eq (Data.Singletons.Class.SomeSingWith1 kproxy f) instance forall kproxy1 kproxy2 (f :: kproxy1 -> kproxy2 -> *). (Data.Singletons.Class.ShowKind kproxy1, Data.Singletons.Class.ShowKind kproxy2, Data.Singletons.Class.ShowSing2 f) => GHC.Show.Show (Data.Singletons.Class.SomeSingWith2 kproxy1 kproxy2 f) instance forall k j (f :: k -> j -> *). (Data.Singletons.Class.ReadKind k, Data.Singletons.Class.ReadKind j, Data.Singletons.Class.ReadSing2 f) => GHC.Read.Read (Data.Singletons.Class.SomeSingWith2 k j f) instance forall kproxy1 kproxy2 (f :: kproxy1 -> kproxy2 -> *). (Data.Singletons.Decide.SDecide kproxy1, Data.Singletons.Decide.SDecide kproxy2, Data.Singletons.Class.EqSing2 f) => GHC.Classes.Eq (Data.Singletons.Class.SomeSingWith2 kproxy1 kproxy2 f) instance forall kproxy1 kproxy2 (f :: kproxy1 -> kproxy2 -> *). (Data.Singletons.Class.ToJSONKind kproxy1, Data.Singletons.Class.ToJSONKind kproxy2, Data.Singletons.Class.ToJSONSing2 f) => Data.Aeson.Types.ToJSON.ToJSON (Data.Singletons.Class.SomeSingWith2 kproxy1 kproxy2 f) instance forall k j (f :: k -> j -> *). (Data.Singletons.Class.FromJSONKind k, Data.Singletons.Class.FromJSONKind j, Data.Singletons.Class.FromJSONSing2 f) => Data.Aeson.Types.FromJSON.FromJSON (Data.Singletons.Class.SomeSingWith2 k j f) instance forall k (f :: k -> *). (Data.Singletons.Class.HashableKind k, Data.Singletons.Class.HashableSing1 f) => Data.Hashable.Class.Hashable (Data.Singletons.Class.SomeSingWith1 k f) instance Data.Singletons.Prelude.Eq.SEq kproxy => GHC.Classes.Eq (Data.Singletons.Class.ClassySomeSing kproxy) instance Data.Singletons.Prelude.Ord.SOrd kproxy => GHC.Classes.Ord (Data.Singletons.Class.ClassySomeSing kproxy) -- | This is a dependent version of the Data.Map module from -- containers. -- -- This module was largely copied from the dependent-map -- package. module Data.Singletons.Map data SingMap (k :: Type) (f :: k -> Type) [Tip] :: SingMap k f [Bin] :: !Int -> !(Sing v) -> !(f v) -> !(SingMap k f) -> !(SingMap k f) -> SingMap k f -- | O(1). The empty map. -- --
-- empty == fromList [] -- size empty == 0 --empty :: SingMap k f -- | O(1). A map with a single element. -- --
-- singleton 1 'a' == fromList [(1, 'a')] -- size (singleton 1 'a') == 1 --singleton :: Sing v -> f v -> SingMap k f -- | O(1). Is the map empty? null :: SingMap k f -> Bool -- | O(1). The number of elements in the map. size :: SingMap k f -> Int -- | O(log n). Lookup the value at a key in the map. -- -- The function will return the corresponding value as (Just -- value), or Nothing if the key isn't in the map. lookup :: forall k f v. (SOrd k, SDecide k) => Sing v -> SingMap k f -> Maybe (f v) lookupAssoc :: forall k f v. (SOrd k, SDecide k) => SomeSing k -> SingMap k f -> Maybe (SomeSingWith1 k f) combine :: (SOrd k, SDecide k) => Sing v -> f v -> SingMap k f -> SingMap k f -> SingMap k f insertMax :: Sing v -> f v -> SingMap k f -> SingMap k f insertMin :: Sing v -> f v -> SingMap k f -> SingMap k f merge :: SOrd k => SingMap k f -> SingMap k f -> SingMap k f glue :: SingMap k f -> SingMap k f -> SingMap k f -- | O(log n). Delete and find the minimal element. -- --
-- deleteFindMin (fromList [(5,"a"), (3,"b"), (10,"c")]) == ((3,"b"), fromList[(5,"a"), (10,"c")]) -- deleteFindMin Error: can not return the minimal element of an empty map --deleteFindMin :: SingMap k f -> (SomeSingWith1 k f, SingMap k f) -- | O(log n). Delete and find the maximal element. -- --
-- deleteFindMax (fromList [(5,"a"), (3,"b"), (10,"c")]) == ((10,"c"), fromList [(3,"b"), (5,"a")]) -- deleteFindMax empty Error: can not return the maximal element of an empty map --deleteFindMax :: SingMap k f -> (SomeSingWith1 k f, SingMap k f) delta :: Int ratio :: Int balance :: Sing v -> f v -> SingMap k f -> SingMap k f -> SingMap k f rotateL :: Sing v -> f v -> SingMap k f -> SingMap k f -> SingMap k f rotateR :: Sing v -> f v -> SingMap k f -> SingMap k f -> SingMap k f singleL :: Sing v -> f v -> SingMap k f -> SingMap k f -> SingMap k f singleR :: Sing v -> f v -> SingMap k f -> SingMap k f -> SingMap k f doubleL :: Sing v -> f v -> SingMap k f -> SingMap k f -> SingMap k f doubleR :: Sing v -> f v -> SingMap k f -> SingMap k f -> SingMap k f bin :: Sing v -> f v -> SingMap k f -> SingMap k f -> SingMap k f trim :: SOrd k => (SomeSing k -> Ordering) -> (SomeSing k -> Ordering) -> SingMap k f -> SingMap k f trimLookupLo :: (SOrd k, SDecide k) => SomeSing k -> (SomeSing k -> Ordering) -> SingMap k f -> (Maybe (SomeSingWith1 k f), SingMap k f) filterGt :: (SOrd k, SDecide k) => (SomeSing k -> Ordering) -> SingMap k f -> SingMap k f filterLt :: (SOrd k, SDecide k) => (SomeSing k -> Ordering) -> SingMap k f -> SingMap k f -- | O(log n). Find the value at a key. Calls error when the -- element can not be found. -- --
-- fromList [(5,'a'), (3,'b')] ! 1 Error: element not in the map -- fromList [(5,'a'), (3,'b')] ! 5 == 'a' --(!) :: (SOrd k, SDecide k) => SingMap k f -> Sing v -> f v infixl 9 ! -- | Same as difference. (\\) :: (SOrd k, SDecide k) => SingMap k f -> SingMap k f -> SingMap k f infixl 9 \\ -- | O(log n). Is the key a member of the map? See also -- notMember. member :: forall k f (v :: k). (SOrd k, SDecide k) => Sing v -> SingMap k f -> Bool -- | O(log n). Is the key not a member of the map? See also -- member. notMember :: forall k f (v :: k). (SOrd k, SDecide k) => Sing v -> SingMap k f -> Bool -- | O(log n). Find the value at a key. Calls error when the -- element can not be found. Consider using lookup when elements -- may not be present. find :: (SOrd k, SDecide k) => Sing v -> SingMap k f -> f v -- | O(log n). The expression (findWithDefault def k -- map) returns the value at key k or returns default value -- def when the key is not in the map. findWithDefault :: (SOrd k, SDecide k) => f v -> Sing v -> SingMap k f -> f v -- | O(log n). Insert a new key and value in the map. If the key is -- already present in the map, the associated value is replaced with the -- supplied value. insert is equivalent to insertWith -- const. insert :: forall k f v. (SOrd k, SDecide k) => Sing v -> f v -> SingMap k f -> SingMap k f -- | O(log n). Insert with a function, combining new value and old -- value. insertWith f key value mp will insert the entry -- key :=> value into mp if key does not exist in -- the map. If the key does exist, the function will insert the entry -- key :=> f new_value old_value. insertWith :: (SOrd k, SDecide k) => (f v -> f v -> f v) -> Sing v -> f v -> SingMap k f -> SingMap k f -- | Same as insertWith, but the combining function is applied -- strictly. This is often the most desirable behavior. insertWith' :: (SOrd k, SDecide k) => (f v -> f v -> f v) -> Sing v -> f v -> SingMap k f -> SingMap k f -- | O(log n). Insert with a function, combining key, new value and -- old value. insertWithKey f key value mp will insert -- the entry key :=> value into mp if key does not -- exist in the map. If the key does exist, the function will insert the -- entry key :=> f key new_value old_value. Note that the key -- passed to f is the same key passed to insertWithKey. insertWithKey :: forall k f v. (SOrd k, SDecide k) => (Sing v -> f v -> f v -> f v) -> Sing v -> f v -> SingMap k f -> SingMap k f -- | Same as insertWithKey, but the combining function is applied -- strictly. insertWithKey' :: forall k f v. (SOrd k, SDecide k) => (Sing v -> f v -> f v -> f v) -> Sing v -> f v -> SingMap k f -> SingMap k f -- | O(log n). Combines insert operation with old value retrieval. -- The expression (insertLookupWithKey f k x map) is a -- pair where the first element is equal to (lookup k -- map) and the second element equal to (insertWithKey f -- k x map). insertLookupWithKey :: forall k f v. (SOrd k, SDecide k) => (Sing v -> f v -> f v -> f v) -> Sing v -> f v -> SingMap k f -> (Maybe (f v), SingMap k f) -- | O(log n). A strict version of insertLookupWithKey. insertLookupWithKey' :: forall k f v. (SOrd k, SDecide k) => (Sing v -> f v -> f v -> f v) -> Sing v -> f v -> SingMap k f -> (Maybe (f v), SingMap k f) -- | O(log n). Delete a key and its value from the map. When the key -- is not a member of the map, the original map is returned. delete :: forall k f (v :: k). (SOrd k, SDecide k) => Sing v -> SingMap k f -> SingMap k f -- | O(log n). Update a value at a specific key with the result of -- the provided function. When the key is not a member of the map, the -- original map is returned. adjust :: (SOrd k, SDecide k) => (f v -> f v) -> Sing v -> SingMap k f -> SingMap k f -- | O(log n). Adjust a value at a specific key. When the key is not -- a member of the map, the original map is returned. adjustWithKey :: (SOrd k, SDecide k) => (Sing v -> f v -> f v) -> Sing v -> SingMap k f -> SingMap k f -- | O(log n). The expression (update f k map) -- updates the value x at k (if it is in the map). If -- (f x) is Nothing, the element is deleted. If it is -- (Just y), the key k is bound to the new value -- y. update :: (SOrd k, SDecide k) => (f v -> Maybe (f v)) -> Sing v -> SingMap k f -> SingMap k f -- | O(log n). The expression (updateWithKey f k -- map) updates the value x at k (if it is in the -- map). If (f k x) is Nothing, the element is deleted. -- If it is (Just y), the key k is bound to the -- new value y. updateWithKey :: forall k f v. (SOrd k, SDecide k) => (Sing v -> f v -> Maybe (f v)) -> Sing v -> SingMap k f -> SingMap k f -- | O(log n). Lookup and update. See also updateWithKey. The -- function returns changed value, if it is updated. Returns the original -- key value if the map entry is deleted. updateLookupWithKey :: forall k f v. (SOrd k, SDecide k) => (Sing v -> f v -> Maybe (f v)) -> Sing v -> SingMap k f -> (Maybe (f v), SingMap k f) -- | O(log n). The expression (alter f k map) alters -- the value x at k, or absence thereof. alter -- can be used to insert, delete, or update a value in a Map. In -- short : lookup k (alter f k m) = f (lookup k -- m). alter :: forall k f v. (SOrd k, SDecide k) => (Maybe (f v) -> Maybe (f v)) -> Sing v -> SingMap k f -> SingMap k f -- | O(log n). Return the index of a key. The index is a -- number from 0 up to, but not including, the size of the -- map. Calls error when the key is not a member of the -- map. findIndex :: forall k f (v :: k). (SOrd k, SDecide k) => Sing v -> SingMap k f -> Int -- | O(log n). Lookup the index of a key. The index is a -- number from 0 up to, but not including, the size of the -- map. lookupIndex :: forall k f (v :: k). (SOrd k, SDecide k) => Sing v -> SingMap k f -> Maybe Int -- | O(log n). Retrieve an element by index. Calls -- error when an invalid index is used. elemAt :: Int -> SingMap k f -> SomeSingWith1 k f -- | O(log n). Update the element at index. Calls -- error when an invalid index is used. updateAt :: (forall v. Sing v -> f v -> Maybe (f v)) -> Int -> SingMap k f -> SingMap k f -- | O(log n). Delete the element at index. Defined as -- (deleteAt i map = updateAt (k x -> -- Nothing) i map). deleteAt :: Int -> SingMap k f -> SingMap k f -- | O(log n). The minimal key of the map. Calls error is the -- map is empty. findMin :: SingMap k f -> SomeSingWith1 k f -- | O(log n). The maximal key of the map. Calls error is the -- map is empty. findMax :: SingMap k f -> SomeSingWith1 k f -- | O(log n). Delete the minimal key. Returns an empty map if the -- map is empty. deleteMin :: SingMap k f -> SingMap k f -- | O(log n). Delete the maximal key. Returns an empty map if the -- map is empty. deleteMax :: SingMap k f -> SingMap k f -- | O(log n). Update the value at the minimal key. updateMinWithKey :: (forall v. Sing v -> f v -> Maybe (f v)) -> SingMap k f -> SingMap k f -- | O(log n). Update the value at the maximal key. updateMaxWithKey :: (forall v. Sing v -> f v -> Maybe (f v)) -> SingMap k f -> SingMap k f -- | O(log n). Retrieves the minimal (key :=> value) entry of the -- map, and the map stripped of that element, or Nothing if passed -- an empty map. minViewWithKey :: SingMap k f -> Maybe (SomeSingWith1 k f, SingMap k f) -- | O(log n). Retrieves the maximal (key :=> value) entry of the -- map, and the map stripped of that element, or Nothing if passed -- an empty map. maxViewWithKey :: SingMap k f -> Maybe (SomeSingWith1 k f, SingMap k f) -- | The union of a list of maps: (unions == foldl -- union empty). unions :: (SOrd k, SDecide k) => [SingMap k f] -> SingMap k f -- | The union of a list of maps, with a combining operation: -- (unionsWithKey f == foldl (unionWithKey f) -- empty). unionsWithKey :: (SOrd k, SDecide k) => (forall v. Sing v -> f v -> f v -> f v) -> [SingMap k f] -> SingMap k f -- | O(n+m). The expression (union t1 t2) takes the -- left-biased union of t1 and t2. It prefers -- t1 when duplicate keys are encountered, i.e. -- (union == unionWith const). The -- implementation uses the efficient hedge-union algorithm. -- Hedge-union is more efficient on (bigset `union` smallset). union :: (SOrd k, SDecide k) => SingMap k f -> SingMap k f -> SingMap k f hedgeUnionL :: (SOrd k, SDecide k) => (SomeSing k -> Ordering) -> (SomeSing k -> Ordering) -> SingMap k f -> SingMap k f -> SingMap k f -- | O(n+m). Union with a combining function. The implementation -- uses the efficient hedge-union algorithm. Hedge-union is more -- efficient on (bigset `union` smallset). unionWithKey :: (SOrd k, SDecide k) => (forall v. Sing v -> f v -> f v -> f v) -> SingMap k f -> SingMap k f -> SingMap k f hedgeUnionWithKey :: forall k f. (SOrd k, SDecide k) => (forall v. Sing v -> f v -> f v -> f v) -> (SomeSing k -> Ordering) -> (SomeSing k -> Ordering) -> SingMap k f -> SingMap k f -> SingMap k f -- | O(n+m). Difference of two maps. Return elements of the first -- map not existing in the second map. The implementation uses an -- efficient hedge algorithm comparable with hedge-union. difference :: (SOrd k, SDecide k) => SingMap k f -> SingMap k g -> SingMap k f hedgeDiff :: (SOrd k, SDecide k) => (SomeSing k -> Ordering) -> (SomeSing k -> Ordering) -> SingMap k f -> SingMap k g -> SingMap k f -- | O(n+m). Difference with a combining function. When two equal -- keys are encountered, the combining function is applied to the key and -- both values. If it returns Nothing, the element is discarded -- (proper set difference). If it returns (Just y), the -- element is updated with a new value y. The implementation -- uses an efficient hedge algorithm comparable with -- hedge-union. differenceWithKey :: (SOrd k, SDecide k) => (forall v. Sing v -> f v -> g v -> Maybe (f v)) -> SingMap k f -> SingMap k g -> SingMap k f hedgeDiffWithKey :: (SOrd k, SDecide k) => (forall v. Sing v -> f v -> g v -> Maybe (f v)) -> (SomeSing k -> Ordering) -> (SomeSing k -> Ordering) -> SingMap k f -> SingMap k g -> SingMap k f -- | O(n+m). Intersection of two maps. Return data in the first map -- for the keys existing in both maps. (intersection m1 m2 == -- intersectionWith const m1 m2). intersection :: (SOrd k, SDecide k) => SingMap k f -> SingMap k f -> SingMap k f -- | O(n+m). Intersection with a combining function. Intersection is -- more efficient on (bigset `intersection` smallset). intersectionWithKey :: (SOrd k, SDecide k) => (forall v. Sing v -> f v -> g v -> h v) -> SingMap k f -> SingMap k g -> SingMap k h -- | O(n). Filter all keys/values that satisfy the predicate. filterWithKey :: (SOrd k, SDecide k) => (forall v. Sing v -> f v -> Bool) -> SingMap k f -> SingMap k f -- | O(n). Partition the map according to a predicate. The first map -- contains all elements that satisfy the predicate, the second all -- elements that fail the predicate. See also split. partitionWithKey :: (SOrd k, SDecide k) => (forall v. Sing v -> f v -> Bool) -> SingMap k f -> (SingMap k f, SingMap k f) -- | O(n). Map keys/values and collect the Just results. mapMaybeWithKey :: (SOrd k, SDecide k) => (forall v. Sing v -> f v -> Maybe (g v)) -> SingMap k f -> SingMap k g -- | O(n). Map keys/values and separate the Left and -- Right results. mapEitherWithKey :: (SOrd k, SDecide k) => (forall v. Sing v -> f v -> Either (g v) (h v)) -> SingMap k f -> (SingMap k g, SingMap k h) -- | O(n). Map a function over all values in the map. mapWithKey :: (forall v. Sing v -> f v -> g v) -> SingMap k f -> SingMap k g -- | O(n). The function mapAccumLWithKey threads an -- accumulating argument throught the map in ascending order of keys. mapAccumLWithKey :: (forall v. a -> Sing v -> f v -> (a, g v)) -> a -> SingMap k f -> (a, SingMap k g) -- | O(n). The function mapAccumRWithKey threads an -- accumulating argument through the map in descending order of keys. mapAccumRWithKey :: (forall v. a -> Sing v -> f v -> (a, g v)) -> a -> SingMap k f -> (a, SingMap k g) -- | O(n*log n). mapKeysWith c f s is the map -- obtained by applying f to each key of s. -- -- The size of the result may be smaller if f maps two or more -- distinct keys to the same new key. In this case the associated values -- will be combined using c. mapKeysWith :: (SOrd k2, SDecide -- k2) => (forall v. Sing v -> f v -> f v -> f v) -> -- (forall v. Sing v -> Sing v) -> SingMap k1 f -> SingMap k2 f -- mapKeysWith c f = fromListWithKey c . map fFirst . toList where fFirst -- (SomeSingWith1 x y) = (SomeSingWith1 (f x) y) -- -- O(n). mapKeysMonotonic f s == mapKeys f -- s, but works only when f is strictly monotonic. That is, -- for any values x and y, if x < -- y then f x < f y. The precondition is -- not checked. Semi-formally, we have: -- --
-- and [x < y ==> f x < f y | x <- ls, y <- ls] -- ==> mapKeysMonotonic f s == mapKeys f s -- where ls = keys s ---- -- This means that f maps distinct original keys to distinct -- resulting keys. This function has better performance than -- mapKeys. mapKeysMonotonic :: forall (k1 :: KProxy k) k2 f. -- (forall (v :: k). Sing v -> Sing v) -> SingMap k1 f -> -- SingMap k2 f mapKeysMonotonic _ Tip = Tip mapKeysMonotonic f (Bin sz k -- x l r) = Bin sz (f k) x (mapKeysMonotonic f l) (mapKeysMonotonic f r) -- -- O(n). Fold the keys and values in the map, such that -- foldWithKey f z == foldr (uncurry f) z . -- toAscList. -- -- This is identical to foldrWithKey, and you should use that one -- instead of this one. This name is kept for backward compatibility. -- | Deprecated: Use foldrWithKey instead foldWithKey :: (forall v. Sing v -> f v -> b -> b) -> b -> SingMap k f -> b -- | O(n). Post-order fold. The function will be applied from the -- lowest value to the highest. foldrWithKey :: (forall v. Sing v -> f v -> b -> b) -> b -> SingMap k f -> b -- | O(n). Pre-order fold. The function will be applied from the -- highest value to the lowest. foldlWithKey :: (forall v. b -> Sing v -> f v -> b) -> b -> SingMap k f -> b -- | O(n). Return all keys of the map in ascending order. -- --
-- keys (fromList [(5,"a"), (3,"b")]) == [3,5] -- keys empty == [] --keys :: SingMap k f -> [SomeSing k] -- | O(n). Return all key/value pairs in the map in ascending key -- order. assocs :: SingMap k f -> [SomeSingWith1 k f] -- | O(n*log n). Build a map from a list of key/value pairs. See -- also fromAscList. If the list contains more than one value for -- the same key, the last value for the key is retained. fromList :: (SOrd k, SDecide k) => [SomeSingWith1 k f] -> SingMap k f -- | O(n*log n). Build a map from a list of key/value pairs with a -- combining function. See also fromAscListWithKey. fromListWithKey :: (SOrd k, SDecide k) => (forall v. Sing v -> f v -> f v -> f v) -> [SomeSingWith1 k f] -> SingMap k f -- | O(n). Convert to a list of key/value pairs. toList :: SingMap k f -> [SomeSingWith1 k f] -- | O(n). Convert to an ascending list. toAscList :: SingMap k f -> [SomeSingWith1 k f] -- | O(n). Convert to a descending list. toDescList :: SingMap k f -> [SomeSingWith1 k f] -- | O(n). Build a map from an ascending list in linear time. The -- precondition (input list is ascending) is not checked. fromAscList :: (SEq k, SDecide k) => [SomeSingWith1 k f] -> SingMap k f -- | O(n). Build a map from an ascending list in linear time with a -- combining function for equal keys. The precondition (input list is -- ascending) is not checked. fromAscListWithKey :: (SEq k, SDecide k) => (forall v. Sing v -> f v -> f v -> f v) -> [SomeSingWith1 k f] -> SingMap k f -- | O(n). Build a map from an ascending list of distinct elements -- in linear time. The precondition is not checked. fromDistinctAscList :: [SomeSingWith1 k f] -> SingMap k f -- | O(log n). The expression (split k map) is a -- pair (map1,map2) where the keys in map1 are smaller -- than k and the keys in map2 larger than k. -- Any key equal to k is found in neither map1 nor -- map2. split :: forall k f (v :: k). (SOrd k, SDecide k) => Sing v -> SingMap k f -> (SingMap k f, SingMap k f) -- | O(log n). The expression (splitLookup k map) -- splits a map just like split but also returns lookup -- k map. splitLookup :: forall k f v. (SOrd k, SDecide k) => Sing v -> SingMap k f -> (SingMap k f, Maybe (f v), SingMap k f) -- | O(log n). splitLookupWithKey :: forall k f v. (SOrd k, SDecide k) => Sing v -> SingMap k f -> (SingMap k f, Maybe (Sing v, f v), SingMap k f) -- | O(n). The expression (showTreeWith showelem hang -- wide map) shows the tree that implements the map. Elements are -- shown using the showElem function. If hang is -- True, a hanging tree is shown otherwise a rotated tree -- is shown. If wide is True, an extra wide version is -- shown. showTreeWith :: (forall v. Sing v -> f v -> String) -> Bool -> Bool -> SingMap k f -> String showsTree :: (forall v. Sing v -> f v -> String) -> Bool -> [String] -> [String] -> SingMap k f -> ShowS showsTreeHang :: (forall v. Sing v -> f v -> String) -> Bool -> [String] -> SingMap k f -> ShowS showWide :: Bool -> [String] -> String -> String showsBars :: [String] -> ShowS node :: String withBar :: [String] -> [String] withEmpty :: [String] -> [String] -- | O(n). Test if the internal map structure is valid. valid :: (SOrd k, SDecide k) => SingMap k f -> Bool ordered :: (SOrd k, SDecide k) => SingMap k f -> Bool -- | Exported only for Debug.QuickCheck balanced :: SingMap k f -> Bool validsize :: SingMap k f -> Bool foldlStrict :: (a -> b -> a) -> a -> [b] -> a ltSome :: SOrd k => SomeSing k -> SomeSing k -> Bool gtSome :: SOrd k => SomeSing k -> SomeSing k -> Bool unifyOnCompareEQ :: forall k (a :: k) (b :: k) x. (SDecide k, Compare a b ~ EQ) => Sing a -> Sing b -> (a ~ b => x) -> x unifyOnEq :: forall k (a :: k) (b :: k) x. (SDecide k, (a :== b) ~ True) => Sing a -> Sing b -> (a ~ b => x) -> x fromRec :: (SOrd k, SDecide k) => Rec (SingWith1 k f) rs -> SingMap k f insertRec :: (SOrd k, SDecide k) => Rec (SingWith1 k f) rs -> SingMap k f -> SingMap k f instance forall k (f :: k -> *). (Data.Singletons.Prelude.Eq.SEq k, Data.Singletons.Decide.SDecide k, Data.Singletons.Class.EqSing1 f) => GHC.Classes.Eq (Data.Singletons.Map.SingMap k f) instance forall k (f :: k -> *). (Data.Singletons.Class.HashableKind k, Data.Singletons.Class.HashableSing1 f) => Data.Hashable.Class.Hashable (Data.Singletons.Map.SingMap k f) instance forall k (f :: k -> *). (Data.Singletons.Class.ToJSONKeyKind k, Data.Singletons.Class.ToJSONSing1 f) => Data.Aeson.Types.ToJSON.ToJSON (Data.Singletons.Map.SingMap k f) instance forall k (f :: k -> *). (Data.Singletons.Prelude.Ord.SOrd k, Data.Singletons.Decide.SDecide k, Data.Singletons.Class.FromJSONKeyKind k, Data.Singletons.Class.FromJSONSing1 f) => Data.Aeson.Types.FromJSON.FromJSON (Data.Singletons.Map.SingMap k f) module Data.Case.Enumerate -- | This will create a pattern match on the first argument that splices in -- the third argument for each pattern. Example: -- --
-- data Color = Red | Blue | Green deriving Show -- myFunc :: Color -> String -- myFunc c = $(enumerateConstructors 'c ''Color =<< [|show c|]) ---- -- I should fix this function to actually make it work that way. It -- actually uses the singletonized data type instead. enumerateConstructors :: Name -> Name -> Exp -> Q Exp