Data.HashMap.Strict: exported symbols usage examples

Symbols

  • ! No usage example found for this symbol :( Collapse [-]
    delete See 26 Occurences [+] Collapse [-]
    Found in Data.Aeson.Diff from the package aeson-diff
    -- | Modify the value associated with a key in a 'HashMap'.
    --
    -- The function is passed the value defined for @k@, or 'Nothing'. If the
    -- function returns 'Nothing', the key and value are deleted from the map;
    -- otherwise the value replaces the existing value in the returned map.
    hmModify
        :: (Eq k, Hashable k)
        => k
        -> (Maybe v -> Result (Maybe v))
        -> HashMap k v
        -> Result (HashMap k v)
    hmModify k f m = case f (HM.lookup k m) of
        Error e          -> Error e
        Success Nothing  -> return $ HM.delete k m
        Success (Just v) -> return $ HM.insert k v m
    
    -- | Report an error about being able to use a pointer key.
    cannot
        :: (Show ix)
    

    Found in Data.Aeson.Diff from the package aeson-diff
                    (\k -> worker (Pointer [OKey k])
                        (fromJust $ HM.lookup k o1)
                        (fromJust $ HM.lookup k o2))
                    chg_keys
            in modifyPointer (path <>) <$> (deletions <> insertions <> changes)
    
        -- Use an adaption of the Wagner-Fischer algorithm to find the shortest
        -- sequence of changes between two JSON arrays.
        workArray :: Pointer -> Array -> Array -> [Operation]
        workArray path ss tt = fmap (modifyPointer (path <>)) . snd . fmap concat $ leastChanges params ss tt
          where
            params :: Params Value [Operation] (Sum Int)
            params = Params{..}
            equivalent = (==)
            delete i = del cfg (Pointer [AKey i])
            insert i = ins cfg (Pointer [AKey i])
            substitute i = worker (Pointer [AKey i])
            cost = Sum . sum . fmap operationCost
            -- Position is advanced by grouping operations with same "head" index:
            -- + groups of many operations advance one
    

    Found in Data.Cache from the package cache
    -- | STM variant of 'size'
    sizeSTM :: Cache k v -> STM Int
    sizeSTM c = HM.size <$> readTVar (container c)
    
    -- | Return the size of the cache, including expired items.
    size :: Cache k v -> IO Int
    size = atomically . sizeSTM
    
    -- | STM variant of 'delete'.
    deleteSTM :: (Eq k, Hashable k) => k -> Cache k v -> STM ()
    deleteSTM k c = writeTVar v =<< (HM.delete k <$> readTVar v) where v = container c
    
    -- | Delete an item from the cache. Won't do anything if the item is not present.
    delete :: (Eq k, Hashable k) => Cache k v -> k -> IO ()
    delete c k = atomically $ deleteSTM k c
    
    lookupItem' :: (Eq k, Hashable k) => k -> Cache k v -> STM (Maybe (CacheItem v))
    lookupItem' k c = HM.lookup k <$> readTVar (container c)
    
    lookupItemT :: (Eq k, Hashable k) => Bool -> k -> Cache k v -> TimeSpec -> STM (Maybe (CacheItem v))
    

    Found in Data.Cache from the package cache
    -- | STM variant of 'size'
    sizeSTM :: Cache k v -> STM Int
    sizeSTM c = HM.size <$> readTVar (container c)
    
    -- | Return the size of the cache, including expired items.
    size :: Cache k v -> IO Int
    size = atomically . sizeSTM
    
    -- | STM variant of 'delete'.
    deleteSTM :: (Eq k, Hashable k) => k -> Cache k v -> STM ()
    deleteSTM k c = writeTVar v =<< (HM.delete k <$> readTVar v) where v = container c
    
    -- | Delete an item from the cache. Won't do anything if the item is not present.
    delete :: (Eq k, Hashable k) => Cache k v -> k -> IO ()
    delete c k = atomically $ deleteSTM k c
    
    lookupItem' :: (Eq k, Hashable k) => k -> Cache k v -> STM (Maybe (CacheItem v))
    lookupItem' k c = HM.lookup k <$> readTVar (container c)
    

    Found in Data.Cache from the package cache
    -- | Create a deep copy of the cache.
    copyCache :: Cache k v -> IO (Cache k v)
    copyCache = atomically . copyCacheSTM
    
    -- | STM variant of 'size'
    sizeSTM :: Cache k v -> STM Int
    sizeSTM c = HM.size <$> readTVar (container c)
    
    -- | Return the size of the cache, including expired items.
    size :: Cache k v -> IO Int
    size = atomically . sizeSTM
    
    -- | STM variant of 'delete'.
    deleteSTM :: (Eq k, Hashable k) => k -> Cache k v -> STM ()
    deleteSTM k c = writeTVar v =<< (HM.delete k <$> readTVar v) where v = container c
    
    -- | Delete an item from the cache. Won't do anything if the item is not present.
    delete :: (Eq k, Hashable k) => Cache k v -> k -> IO ()
    delete c k = atomically $ deleteSTM k c
    

    Found in Data.Cache from the package cache
      , copyCacheSTM
    
        -- * Managing items
        -- ** Insertion
      , insert
      , insert'
      , insertSTM
        -- ** Querying
      , lookup
      , lookup'
      , lookupSTM
      , keys
      , keysSTM
        -- ** Deletion
      , delete
      , deleteSTM
      , purgeExpired
      , purgeExpiredSTM
    
        -- * Cache information
    

    Found in Caching.ExpiringCacheMap.HashECM from the package expiring-cache-map
    --   mutable cache container (e.g. 'MV.readMVar' followed by 'MV.modifyMVar'
    --   with 'newECMIO' instances).
    --
    invalidate :: (Monad m, Eq k, Hashable k) => ECM m mv s HM.HashMap k v -> k -> m (Maybe v)
    invalidate ecm id = do
      CacheState (_, maps0, _, _, _) <- read m'maps
      case HM.lookup id maps0 of
        Just time_prev0 -> do
          prev0' <- enter m'maps $
            \(CacheState (retr_state, maps, mapsize, uses, incr)) ->
              let (_, _, prev) =
                    case HM.lookup id maps of
                      Just time_prev -> time_prev
                      Nothing -> time_prev0
                  maps' = HM.delete id maps
               in return (CacheState (retr_state, maps', mapsize, uses, incr), prev)
          return $ Just prev0'
        Nothing -> return Nothing
      where
        ECM ( m'maps, _, _, _, _, _, compactlistsize, enter, read ) = ecm
    

    Found in Text.Glabrous from the package glabrous
          case uncons _ts of
            Just ((k,v),ts') -> go ts' $ H.insert k v vs
            Nothing          -> Context { variables = vs }
    
    -- | Delete variables from a 'Context' by these names.
    --
    -- >λ>deleteVariables ["tag"] context
    -- >Context {variables = fromList [("etc.","..."),("theme","Haskell"),("name","")]}
    deleteVariables :: [T.Text] -> Context -> Context
    deleteVariables ts Context{..} =
      go ts variables
      where
        go _ts vs =
          case uncons _ts of
            Just (k,ts') -> go ts' $ H.delete k vs
            Nothing      -> Context { variables = vs }
    
    -- | Build a 'Context' from a list of 'Tag's and replacement 'T.Text's.
    --
    -- >λ>fromList [("tag","replacement"), ("etc.","...")]
    

    Found in Data.Core.Graph.NodeManager from the package graph-core
              Just i -> return i
              Nothing ->
                do let i = nm_nextNode
                   put $! NodeManager { nm_nodeToKey = IM.insert i k nm_nodeToKey
                                      , nm_keyToNode = HM.insert k i nm_keyToNode
                                      , nm_nextNode = i + 1
                                      }
                   return i
    
    removeNodeHandle :: (Hashable k, Eq k) => Node -> NodeManager k -> NodeManager k
    removeNodeHandle i nm@(NodeManager{..}) =
        case IM.lookup i nm_nodeToKey of
          Just k ->
              nm { nm_nodeToKey = IM.delete i nm_nodeToKey
                 , nm_keyToNode = HM.delete k nm_keyToNode
                 }
          Nothing -> nm
    
    getExistingNodeHandle :: (Hashable k, Eq k) => k -> NodeManager k -> Maybe Node
    getExistingNodeHandle k (NodeManager{..}) = HM.lookup k nm_keyToNode
    

    Found in Data.Core.Graph.NodeManager from the package graph-core
           case HM.lookup k nm_keyToNode of
              Just i -> return i
              Nothing ->
                do let i = nm_nextNode
                   put $! NodeManager { nm_nodeToKey = IM.insert i k nm_nodeToKey
                                      , nm_keyToNode = HM.insert k i nm_keyToNode
                                      , nm_nextNode = i + 1
                                      }
                   return i
    
    removeNodeHandle :: (Hashable k, Eq k) => Node -> NodeManager k -> NodeManager k
    removeNodeHandle i nm@(NodeManager{..}) =
        case IM.lookup i nm_nodeToKey of
          Just k ->
              nm { nm_nodeToKey = IM.delete i nm_nodeToKey
                 , nm_keyToNode = HM.delete k nm_keyToNode
                 }
          Nothing -> nm
    
    getExistingNodeHandle :: (Hashable k, Eq k) => k -> NodeManager k -> Maybe Node
    

    Found in Data.Greskell.Graph from the package greskell
    instance (Foldable t, Foldable p) => Foldable (PropertyMapGeneric t p) where
      foldr f start (PropertyMapGeneric hm) = foldr f2 start hm
        where
          f2 t start2 = foldr f3 start2 t
          f3 p start3 = foldr f start3 p
    
    instance (Traversable t, Traversable p) => Traversable (PropertyMapGeneric t p) where
      traverse f (PropertyMapGeneric hm) = fmap PropertyMapGeneric $ (traverse . traverse . traverse) f hm
    
    putPropertyGeneric :: (Semigroup (t (p v)), Applicative t, Property p) => p v -> PropertyMapGeneric t p v -> PropertyMapGeneric t p v
    putPropertyGeneric prop (PropertyMapGeneric hm) =
      PropertyMapGeneric $ HM.insertWith (<>) (propertyKey prop) (pure prop) hm
    
    removePropertyGeneric :: Text -> PropertyMapGeneric t p v -> PropertyMapGeneric t p v
    removePropertyGeneric k (PropertyMapGeneric hm) = PropertyMapGeneric $ HM.delete k hm
    
    allPropertiesGeneric :: Foldable t => PropertyMapGeneric t p v -> [p v]
    allPropertiesGeneric (PropertyMapGeneric hm) = concat $ map toList $ HM.elems hm
    
    parsePropertiesGeneric :: (Property p, PropertyMap m, Monoid (m p v), GraphSONTyped (p v), FromGraphSON (p v), FromGraphSONWithKey (p v))
    

    Found in Network.Http.Internal from the package http-common
    updateHeader x k v =
        Wrap result
      where
        !result = insert (mk k) v m
        !m = unWrap x
    
    --
    -- | Remove a header from the map. If a field with that name is not present,
    -- then this will have no effect.
    --
    removeHeader :: Headers -> ByteString -> Headers
    removeHeader x k =
        Wrap result
      where
        !result = delete (mk k) m
        !m = unWrap x
    
    
    --
    -- | Given a list of field-name,field-value pairs, construct a Headers map.
    

    Found in Network.Http.Internal from the package http-common
    import Blaze.ByteString.Builder (Builder)
    import qualified Blaze.ByteString.Builder as Builder (copyByteString,
                                                          copyByteString,
                                                          fromByteString,
                                                          fromByteString,
                                                          toByteString)
    import qualified Blaze.ByteString.Builder.Char8 as Builder (fromChar,
                                                                fromShow,
                                                                fromString)
    import Control.Exception (Exception)
    import Data.ByteString (ByteString)
    import qualified Data.ByteString.Char8 as S
    import Data.CaseInsensitive (CI, mk, original)
    import Data.HashMap.Strict (HashMap, delete, empty, foldrWithKey, insert,
                                insertWith, lookup, toList)
    import Data.Int (Int64)
    import Data.List (foldl')
    import Data.Monoid (mconcat, mempty)
    import Data.Typeable (Typeable)
    

    Found in Data.Aeson.AutoType.Split from the package json-autotype
        candidates [_] = False
        candidates _   = True
        -- | Make a candidate entry for each object type, which points from its keys to its label.
        entry (k, TObj o)                 = [(Set.fromList $ Map.keys $ unDict o, [k])]
        entry  _                          = [] -- ignore array elements and toplevel type if it is Array
    
    -- | Unifies candidates on a give input list.
    unifyCandidates :: [[Text]] -> Map Text Type -> Map Text Type
    unifyCandidates candidates splitted = Map.map (remapLabels labelMapping) $ replacements splitted
      where
        unifiedType  :: [Text] -> Type
        unifiedType cset      = foldr1 unifyTypes         $ 
                                map (splitted Map.!) cset
        replace      :: [Text] -> Map Text Type -> Map Text Type
        replace  cset@(c:_) s = Map.insert c (unifiedType cset) (foldr Map.delete s cset)
        replace  []         _ = error "Empty candidate set in replace"
        replacements :: Map Text Type -> Map Text Type
        replacements        s = foldr replace s candidates
        labelMapping :: Map Text Text
        labelMapping          = Map.fromList $ concatMap mapEntry candidates
    

    Found in Data.Aeson.AutoType.Split from the package json-autotype
        candidates [_] = False
        candidates _   = True
        -- | Make a candidate entry for each object type, which points from its keys to its label.
        entry (k, TObj o)                 = [(Set.fromList $ Map.keys $ unDict o, [k])]
        entry  _                          = [] -- ignore array elements and toplevel type if it is Array
    
    -- | Unifies candidates on a give input list.
    unifyCandidates :: [[Text]] -> Map Text Type -> Map Text Type
    unifyCandidates candidates splitted = Map.map (remapLabels labelMapping) $ replacements splitted
      where
        unifiedType  :: [Text] -> Type
        unifiedType cset      = foldr1 unifyTypes         $ 
                                map (splitted Map.!) cset
        replace      :: [Text] -> Map Text Type -> Map Text Type
        replace  cset@(c:_) s = Map.insert c (unifiedType cset) (foldr Map.delete s cset)
        replace  []         _ = error "Empty candidate set in replace"
        replacements :: Map Text Type -> Map Text Type
        replacements        s = foldr replace s candidates
        labelMapping :: Map Text Text
        labelMapping          = Map.fromList $ concatMap mapEntry candidates
    

    Found in Data.Aeson.AutoType.Split from the package json-autotype
        candidates [_] = False
        candidates _   = True
        -- | Make a candidate entry for each object type, which points from its keys to its label.
        entry (k, TObj o)                 = [(Set.fromList $ Map.keys $ unDict o, [k])]
        entry  _                          = [] -- ignore array elements and toplevel type if it is Array
    
    -- | Unifies candidates on a give input list.
    unifyCandidates :: [[Text]] -> Map Text Type -> Map Text Type
    unifyCandidates candidates splitted = Map.map (remapLabels labelMapping) $ replacements splitted
      where
        unifiedType  :: [Text] -> Type
        unifiedType cset      = foldr1 unifyTypes         $ 
                                map (splitted Map.!) cset
        replace      :: [Text] -> Map Text Type -> Map Text Type
        replace  cset@(c:_) s = Map.insert c (unifiedType cset) (foldr Map.delete s cset)
        replace  []         _ = error "Empty candidate set in replace"
        replacements :: Map Text Type -> Map Text Type
        replacements        s = foldr replace s candidates
        labelMapping :: Map Text Text
        labelMapping          = Map.fromList $ concatMap mapEntry candidates
    

    Found in Data.Aeson.AutoType.Split from the package json-autotype
        candidates [_] = False
        candidates _   = True
        -- | Make a candidate entry for each object type, which points from its keys to its label.
        entry (k, TObj o)                 = [(Set.fromList $ Map.keys $ unDict o, [k])]
        entry  _                          = [] -- ignore array elements and toplevel type if it is Array
    
    -- | Unifies candidates on a give input list.
    unifyCandidates :: [[Text]] -> Map Text Type -> Map Text Type
    unifyCandidates candidates splitted = Map.map (remapLabels labelMapping) $ replacements splitted
      where
        unifiedType  :: [Text] -> Type
        unifiedType cset      = foldr1 unifyTypes         $ 
                                map (splitted Map.!) cset
        replace      :: [Text] -> Map Text Type -> Map Text Type
        replace  cset@(c:_) s = Map.insert c (unifiedType cset) (foldr Map.delete s cset)
        replace  []         _ = error "Empty candidate set in replace"
        replacements :: Map Text Type -> Map Text Type
        replacements        s = foldr replace s candidates
        labelMapping :: Map Text Text
        labelMapping          = Map.fromList $ concatMap mapEntry candidates
    

    Found in Internal from the package json-rpc-server
    params :: A.Value -> Maybe A.Value -> A.Value
    params rq = insert rq "params"
    
    id' :: A.Value -> Maybe A.Value -> A.Value
    id' rq = insert rq "id"
    
    version :: A.Value -> Maybe A.Value -> A.Value
    version rq = insert rq "jsonrpc"
    
    result :: A.Value -> A.Value -> A.Value
    result rsp = insert rsp "result" . Just
    
    insert :: A.Value -> Text -> Maybe A.Value -> A.Value
    insert (A.Object obj) key Nothing = A.Object $ H.delete key obj
    insert (A.Object obj) key (Just val) = A.Object $ H.insert key val obj
    insert v _ _ = v
    
    defaultId :: A.Value
    defaultId = A.Number 3
    

    Found in Data.HashMap.Monoidal from the package monoidal-containers
    lookup :: (Eq k, Hashable k) => k -> MonoidalHashMap k v -> Maybe v
    lookup k = M.lookup k . unpack
    {-# INLINE lookup #-}
    
    -- | /O(log n)/ Return the value to which the specified key is mapped,
    -- or mempty if this map contains no mapping for the key.
    lookupM :: (Eq k, Hashable k, Monoid v) => k -> MonoidalHashMap k v -> v
    lookupM k = fromMaybe mempty . M.lookup k . unpack
    {-# INLINE lookupM #-}
    
    -- | /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 :: (Eq k, Hashable k) => k -> MonoidalHashMap k a -> MonoidalHashMap k a
    delete k = _Wrapping' MonoidalHashMap %~ M.delete k
    {-# INLINE delete #-}
    
    -- | /O(n)/.
    -- Return a list of this map's values. The list is produced lazily.
    elems :: MonoidalHashMap k a -> [a]
    elems = M.elems . unpack
    

    Found in Data.HashMap.Monoidal from the package monoidal-containers
    -- or 'Nothing' if this map contains no mapping for the key.
    lookup :: (Eq k, Hashable k) => k -> MonoidalHashMap k v -> Maybe v
    lookup k = M.lookup k . unpack
    {-# INLINE lookup #-}
    
    -- | /O(log n)/ Return the value to which the specified key is mapped,
    -- or mempty if this map contains no mapping for the key.
    lookupM :: (Eq k, Hashable k, Monoid v) => k -> MonoidalHashMap k v -> v
    lookupM k = fromMaybe mempty . M.lookup k . unpack
    {-# INLINE lookupM #-}
    
    -- | /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 :: (Eq k, Hashable k) => k -> MonoidalHashMap k a -> MonoidalHashMap k a
    delete k = _Wrapping' MonoidalHashMap %~ M.delete k
    {-# INLINE delete #-}
    
    -- | /O(n)/.
    -- Return a list of this map's values. The list is produced lazily.
    elems :: MonoidalHashMap k a -> [a]
    

    Found in Data.HashMap.Monoidal from the package monoidal-containers
    -- or 'Nothing' if this map contains no mapping for the key.
    lookup :: (Eq k, Hashable k) => k -> MonoidalHashMap k v -> Maybe v
    lookup k = M.lookup k . unpack
    {-# INLINE lookup #-}
    
    -- | /O(log n)/ Return the value to which the specified key is mapped,
    -- or mempty if this map contains no mapping for the key.
    lookupM :: (Eq k, Hashable k, Monoid v) => k -> MonoidalHashMap k v -> v
    lookupM k = fromMaybe mempty . M.lookup k . unpack
    {-# INLINE lookupM #-}
    
    -- | /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 :: (Eq k, Hashable k) => k -> MonoidalHashMap k a -> MonoidalHashMap k a
    delete k = _Wrapping' MonoidalHashMap %~ M.delete k
    {-# INLINE delete #-}
    
    -- | /O(n)/.
    -- Return a list of this map's values. The list is produced lazily.
    elems :: MonoidalHashMap k a -> [a]
    

    Found in Data.HashMap.Monoidal from the package monoidal-containers
    -- | /O(log n)/ Return the value to which the specified key is mapped,
    -- or 'Nothing' if this map contains no mapping for the key.
    lookup :: (Eq k, Hashable k) => k -> MonoidalHashMap k v -> Maybe v
    lookup k = M.lookup k . unpack
    {-# INLINE lookup #-}
    
    -- | /O(log n)/ Return the value to which the specified key is mapped,
    -- or mempty if this map contains no mapping for the key.
    lookupM :: (Eq k, Hashable k, Monoid v) => k -> MonoidalHashMap k v -> v
    lookupM k = fromMaybe mempty . M.lookup k . unpack
    {-# INLINE lookupM #-}
    
    -- | /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 :: (Eq k, Hashable k) => k -> MonoidalHashMap k a -> MonoidalHashMap k a
    delete k = _Wrapping' MonoidalHashMap %~ M.delete k
    {-# INLINE delete #-}
    
    -- | /O(n)/.
    -- Return a list of this map's values. The list is produced lazily.
    

    Found in Data.HashMap.Monoidal from the package monoidal-containers
        deriving (Show, Read, Functor, Eq, NFData,
                  Foldable, Traversable,
                  Data, Typeable)
    
    type instance Index (MonoidalHashMap k a) = k
    type instance IxValue (MonoidalHashMap k a) = a
    instance (Eq k, Hashable k) => Ixed (MonoidalHashMap k a) where
        ix k f (MonoidalHashMap m) = case M.lookup k m of
          Just v  -> f v <&> \v' -> MonoidalHashMap (M.insert k v' m)
          Nothing -> pure (MonoidalHashMap m)
        {-# INLINE ix #-}
    
    instance (Eq k, Hashable k) => At (MonoidalHashMap k a) where
        at k f (MonoidalHashMap m) = f mv <&> \r -> case r of
          Nothing -> maybe (MonoidalHashMap m) (const (MonoidalHashMap $ M.delete k m)) mv
          Just v' -> MonoidalHashMap $ M.insert k v' m
          where mv = M.lookup k m
        {-# INLINE at #-}
    
    instance Each (MonoidalHashMap k a) (MonoidalHashMap k b) a b
    

    Found in Data.HashMap.Monoidal from the package monoidal-containers
    module Data.HashMap.Monoidal
        ( MonoidalHashMap(..)
          -- * Often-needed functions
        , toList
        , fromList
        , singleton
        , size
        , member
        , notMember
        , lookup
        , lookupM
        , elems
        , keys
        , delete
        , mapKeys
        , modify
        , modifyDef
        , map
        , filterWithKey
    

    Found in RIO.HashMap from the package rio
        Data.HashMap.Strict.HashMap
    
        -- * Construction
      , Data.HashMap.Strict.empty
      , Data.HashMap.Strict.singleton
    
        -- * Basic interface
      , Data.HashMap.Strict.null
      , Data.HashMap.Strict.size
      , Data.HashMap.Strict.member
      , Data.HashMap.Strict.lookup
      , Data.HashMap.Strict.lookupDefault
      , Data.HashMap.Strict.insert
      , Data.HashMap.Strict.insertWith
      , Data.HashMap.Strict.delete
      , Data.HashMap.Strict.adjust
      , Data.HashMap.Strict.update
      , Data.HashMap.Strict.alter
    
        -- * Combine
    

    Found in Xmlbf from the package xmlbf
        unParser (pElement t0 p0) (SReg as cs)
      STop (Text' x : cs) | T.all Char.isSpace x ->
        unParser (pElement t0 p0) (STop cs)
      _ -> Left ("Missing element " ++ show t0)
    
    -- | Return the value of the requested attribute, if defined. May return an
    -- empty string in case the attribute is defined but no value was given to it.
    --
    -- Consumes the attribute from the parser state.
    pAttr :: T.Text -> Parser T.Text
    {-# INLINABLE pAttr #-}
    pAttr n = Parser $ \case
      STop _ -> Left "Before selecting an attribute, you must select an element"
      SReg as cs -> case HM.lookup n as of
        Just x -> Right (x, SReg (HM.delete n as) cs)
        Nothing -> Left ("Missing attribute " ++ show n)
    
    -- | Returns all of the available element attributes. May return empty strings
    -- as values in case an attribute is defined but no value was given to it.
    --
    

    difference See 1 Occurences [+] Collapse [-]
    Found in RIO.HashMap from the package rio
        -- * Combine
        -- ** Union
      , Data.HashMap.Strict.union
      , Data.HashMap.Strict.unionWith
      , Data.HashMap.Strict.unionWithKey
      , Data.HashMap.Strict.unions
    
        -- * Transformations
      , Data.HashMap.Strict.map
      , Data.HashMap.Strict.mapWithKey
      , Data.HashMap.Strict.traverseWithKey
    
        -- * Difference and intersection
      , Data.HashMap.Strict.difference
      , Data.HashMap.Strict.differenceWith
      , Data.HashMap.Strict.intersection
      , Data.HashMap.Strict.intersectionWith
      , Data.HashMap.Strict.intersectionWithKey
    

    elems See 80 Occurences [+] Collapse [-]
    Found in Data.Aeson.Diff from the package aeson-diff
    -- | Calculate the cost of an operation.
    operationCost :: Operation -> Int
    operationCost op =
        case op of
          Add{} -> valueSize (changeValue op)
          Rem{} -> 1
          Rep{} -> valueSize (changeValue op)
          Mov{} -> 1
          Cpy{} -> 1
          Tst{} -> valueSize (changeValue op)
    
    -- | Estimate the size of a JSON 'Value'.
    valueSize :: Value -> Int
    valueSize val = case val of
        Object o -> sum . fmap valueSize . HM.elems $ o
        Array  a -> V.sum $ V.map valueSize a
        _        -> 1
    
    -- * Atomic patches
    

    Found in Data.FuzzySet from the package fuzzyset
    size = HashMap.size  exactSet
    
    -- | Return a boolean indicating whether the provided set is empty.
    --
    -- >>> isEmpty (fromList [])
    -- True
    isEmpty  FuzzySet  Bool
    isEmpty = HashMap.null  exactSet
    
    -- | Return the elements of the set.
    --
    -- >>> values (fromList ["bass", "craze", "space", "lace", "daze", "haze", "ace", "maze"])
    -- ["space","daze","bass","maze","ace","craze","lace","haze"]
    values  FuzzySet  [Text]
    values = elems  exactSet
    

    Found in Data.FuzzySet from the package fuzzyset
              Text
             -- ^ The new entry
              (FuzzySet, Bool)
             -- ^ The updated set and a boolean, which will be 'True' if, and only 
             --   if, the value was not already in the set 
    addToSet FuzzySet{..} val
        | key  exactSet = (FuzzySet{..}, False)
        | otherwise =
          let sizes = [gramSizeLower .. gramSizeUpper]
           in (foldr ξ FuzzySet{..} sizes &_exactSet %~ insert key val, True)
      where
        key = Text.toLower val
        ξ size fs =
          let dict' = flip (:) []  GramInfo index <$> gramMap (normalized val) size
              item  = FuzzySetItem (gramMap key size & elems & norm) key
              index = fs ^._items ^? ix size ^._Just & Vector.length
           in over _matchDict (\dict  unionWith () dict dict')
            $ over (_items.at size) (Just  (`Vector.snoc` item)
                                           fromMaybe Vector.empty) fs
    

    Found in Data.FuzzySet from the package fuzzyset
      , getWithMinScore
      , getOne
    
      -- ** Inspecting
      , size
      , isEmpty
      , values
      ) where
    
    import Data.Foldable.Unicode
    import Data.FuzzySet.Internal
    import Data.FuzzySet.Lens
    import Data.FuzzySet.Types
    import Data.FuzzySet.Util
    import Data.HashMap.Strict             ( HashMap, elems, insert, unionWith )
    import Data.Maybe                      ( fromMaybe )
    import Data.List                       ( find )
    import Data.Text                       ( Text )
    import Prelude.Unicode                 hiding ( () )
    

    Found in Data.FuzzySet.Internal from the package fuzzyset
      where
        match α = set ^._exactSet.ix α
        filtered = filter ((<) minScore  fst) sorted
        μ p = p & _1.~ distance (p ^._2) key
        sorted = sortBy (flip compare `on` fst) $
            let rs = results GetContext{..} size
             in if set ^._useLevenshtein
                    then take 50 (μ <$> rs)
                    else rs
    
    results  GetContext  Size  [(Double, Text)]
    results GetContext{..} size = ζ <$> HashMap.toList (matches set grams)
      where
        grams  = gramMap key size
        normal = norm (elems grams)
        ζ (index, score) =
          let FuzzySetItem{..} = Vector.unsafeIndex (set ^._items.ix size) index
           in (fromIntegral score / (normal × vectorMagnitude), normalizedEntry)
    
    matches  FuzzySet  HashMap Text Int  HashMap Int Int
    

    Found in Data.FuzzySet.Internal from the package fuzzyset
    {-# LANGUAGE FlexibleContexts  #-}
    {-# LANGUAGE RecordWildCards #-}
    {-# LANGUAGE UnicodeSyntax   #-}
    module Data.FuzzySet.Internal where
    
    import Data.Function                   ( on )
    import Data.FuzzySet.Lens
    import Data.FuzzySet.Types
    import Data.FuzzySet.Util
    import Data.HashMap.Strict             ( HashMap, alter, empty, elems, foldrWithKey )
    import Data.Maybe                      ( fromMaybe )
    import Data.List                       ( sortBy )
    import Data.Text                       ( Text )
    import Prelude.Unicode
    

    Found in Data.Greskell.Graph from the package greskell
          f2 t start2 = foldr f3 start2 t
          f3 p start3 = foldr f start3 p
    
    instance (Traversable t, Traversable p) => Traversable (PropertyMapGeneric t p) where
      traverse f (PropertyMapGeneric hm) = fmap PropertyMapGeneric $ (traverse . traverse . traverse) f hm
    
    putPropertyGeneric :: (Semigroup (t (p v)), Applicative t, Property p) => p v -> PropertyMapGeneric t p v -> PropertyMapGeneric t p v
    putPropertyGeneric prop (PropertyMapGeneric hm) =
      PropertyMapGeneric $ HM.insertWith (<>) (propertyKey prop) (pure prop) hm
    
    removePropertyGeneric :: Text -> PropertyMapGeneric t p v -> PropertyMapGeneric t p v
    removePropertyGeneric k (PropertyMapGeneric hm) = PropertyMapGeneric $ HM.delete k hm
    
    allPropertiesGeneric :: Foldable t => PropertyMapGeneric t p v -> [p v]
    allPropertiesGeneric (PropertyMapGeneric hm) = concat $ map toList $ HM.elems hm
    
    parsePropertiesGeneric :: (Property p, PropertyMap m, Monoid (m p v), GraphSONTyped (p v), FromGraphSON (p v), FromGraphSONWithKey (p v))
                           => (GValue -> Parser (Vector GValue))
                           -> GValue
                           -> Parser (m p v)
    

    Found in Haxl.Core.DataCache from the package haxl
    --
    showCache
      :: forall res
      .  DataCache res
      -> (forall a . res a -> IO (Maybe (Either SomeException a)))
      -> IO [(TypeRep, [(String, Either SomeException String)])]
    
    showCache (DataCache cache) readRes = mapM goSubCache (HashMap.toList cache)
     where
      goSubCache
        :: (TypeRep, SubCache res)
        -> IO (TypeRep,[(String, Either SomeException String)])
      goSubCache (ty, SubCache showReq showRes hmap) = do
        elems <- catMaybes <$> mapM go (HashMap.toList hmap)
        return (ty, elems)
       where
        go  (req, rvar) = do
          maybe_r <- readRes rvar
          case maybe_r of
            Nothing -> return Nothing
    

    Found in Haxl.Core.DataCache from the package haxl
    -- 'insertNotShowable' has been used to insert any entries.
    --
    showCache
      :: forall res
      .  DataCache res
      -> (forall a . res a -> IO (Maybe (Either SomeException a)))
      -> IO [(TypeRep, [(String, Either SomeException String)])]
    
    showCache (DataCache cache) readRes = mapM goSubCache (HashMap.toList cache)
     where
      goSubCache
        :: (TypeRep, SubCache res)
        -> IO (TypeRep,[(String, Either SomeException String)])
      goSubCache (ty, SubCache showReq showRes hmap) = do
        elems <- catMaybes <$> mapM go (HashMap.toList hmap)
        return (ty, elems)
       where
        go  (req, rvar) = do
          maybe_r <- readRes rvar
          case maybe_r of
    

    Found in Data.Aeson.AutoType.Extract from the package json-autotype
                                   then emptyType
                                   else foldl1' unifyTypes arrayElts
    
    -- | Smart constructor for union types.
    union ::  Set Type -> Type
    union = simplifyUnion . TUnion
    
    -- | Simplify TUnion's so there is no TUnion directly inside TUnion.
    -- If there is only one element of the set, then return this single
    -- element as a type.
    simplifyUnion :: Type -> Type
    simplifyUnion (TUnion s) | Set.size s == 1 = head $ Set.toList s
    simplifyUnion (TUnion s)                   = TUnion $ Set.unions $ map elements $ Set.toList s
      where
        elements (TUnion elems) = elems
        elements sing           = Set.singleton sing
    simplifyUnion unexpected                   = error ("simplifyUnion: unexpected argument " ++ show unexpected)
    

    Found in Data.Aeson.AutoType.Extract from the package json-autotype
                                   then emptyType
                                   else foldl1' unifyTypes arrayElts
    
    -- | Smart constructor for union types.
    union ::  Set Type -> Type
    union = simplifyUnion . TUnion
    
    -- | Simplify TUnion's so there is no TUnion directly inside TUnion.
    -- If there is only one element of the set, then return this single
    -- element as a type.
    simplifyUnion :: Type -> Type
    simplifyUnion (TUnion s) | Set.size s == 1 = head $ Set.toList s
    simplifyUnion (TUnion s)                   = TUnion $ Set.unions $ map elements $ Set.toList s
      where
        elements (TUnion elems) = elems
        elements sing           = Set.singleton sing
    simplifyUnion unexpected                   = error ("simplifyUnion: unexpected argument " ++ show unexpected)
    

    Found in Data.Aeson.AutoType.Extract from the package json-autotype
    valueTypeSize (String _) = 1
    valueTypeSize (Array  a) = (1+) . V.foldl' max 0 $ V.map valueTypeSize a
    valueTypeSize (Object o) = (1+) . sum . map valueTypeSize . Map.elems $ o
    
    -- | Compute total depth of the value.
    -- For:
    -- * simple types it is 1
    -- * for either Array or Object, it is 1 + maximum of depths of their members
    valueDepth :: Value -> Int
    valueDepth  Null      = 1
    valueDepth (Bool   _) = 1
    valueDepth (Number _) = 1
    valueDepth (String _) = 1
    valueDepth (Array  a) = (1+) . V.foldl' max 0 $ V.map valueDepth a
    valueDepth (Object o) = (1+) . maximum . (0:) . map valueDepth . Map.elems $ o
    
    -- | Extract @Type@ from the JSON @Value@.
    -- Unifying types of array elements, if necessary.
    extractType                             :: Value -> Type
    extractType (Object o)                   = TObj $ Dict $ Map.map extractType o
    

    Found in Data.Aeson.AutoType.Extract from the package json-autotype
    valueSize (Object o) = (1+) . sum . map valueSize . Map.elems $ o
    
    -- | Compute total size of the type of the @Value@.
    -- For:
    -- * simple types it is always 1,
    -- * for arrays it is just 1+_maximum_ size of the (single) element type,
    -- * for objects it is _sum_ of the sizes of fields (since each field type
    --   is assumed to be different.)
    valueTypeSize :: Value -> Int
    valueTypeSize  Null      = 1
    valueTypeSize (Bool   _) = 1
    valueTypeSize (Number _) = 1
    valueTypeSize (String _) = 1
    valueTypeSize (Array  a) = (1+) . V.foldl' max 0 $ V.map valueTypeSize a
    valueTypeSize (Object o) = (1+) . sum . map valueTypeSize . Map.elems $ o
    
    -- | Compute total depth of the value.
    -- For:
    -- * simple types it is 1
    -- * for either Array or Object, it is 1 + maximum of depths of their members
    

    Found in Data.Aeson.AutoType.Extract from the package json-autotype
    import           Data.List                       (foldl1')
    
    --import           Debug.Trace
    
    -- | Compute total number of nodes (and leaves) within the value tree.
    -- Each simple JavaScript type (including String) is counted as of size 1,
    -- whereas both Array or object types are counted as 1+sum of the sizes
    -- of their member values.
    valueSize :: Value -> Int
    valueSize  Null      = 1
    valueSize (Bool   _) = 1
    valueSize (Number _) = 1
    valueSize (String _) = 1
    valueSize (Array  a) = V.foldl' (+) 1 $ V.map valueSize a
    valueSize (Object o) = (1+) . sum . map valueSize . Map.elems $ o
    
    -- | Compute total size of the type of the @Value@.
    -- For:
    -- * simple types it is always 1,
    -- * for arrays it is just 1+_maximum_ size of the (single) element type,
    

    Found in Data.Aeson.AutoType.Type from the package json-autotype
    -- | Is the top-level constructor a TUnion?
    isUnion           :: Type -> Bool
    isUnion (TUnion _) = True
    isUnion _          = False
    
    -- | Is the top-level constructor a TArray?
    -- | Check if the given type has non-top TObj.
    isArray           :: Type -> Bool
    isArray (TArray _) = True
    isArray _          = False
    
    -- | Check if the given type has non-top TObj.
    hasNonTopTObj         :: Type -> Bool
    hasNonTopTObj (TObj o) = any hasTObj $ Hash.elems $ unDict o
    hasNonTopTObj _        = False
    
    -- | Check if the given type has TObj on top or within array..
    hasTObj           :: Type -> Bool
    hasTObj (TObj   _) = True
    

    Found in Data.Aeson.AutoType.Type from the package json-autotype
    emptyType = TUnion Set.empty
    
    -- | Lookup the Type within the dictionary.
    get :: Text -> Dict -> Type
    get key = Hash.lookupDefault TNull key . unDict
    
    -- $derive makeUniplateDirect ''Type
    
    -- | Size of the `Type` term.
    typeSize           :: Type -> Int
    typeSize TNull      = 1
    typeSize TBool      = 1
    typeSize TNum       = 1
    typeSize TString    = 1
    typeSize (TObj   o) = (1+) . sum     . map typeSize . Hash.elems . unDict $ o
    typeSize (TArray a) = 1 + typeSize a
    typeSize (TUnion u) = (1+) . sum . (0:) . map typeSize . Set.toList $ u
    typeSize (TLabel _) = error "Don't know how to compute typeSize of TLabel."
    
    -- | Check if this is nullable (Maybe) type, or not.
    

    Found in Data.Aeson.AutoType.Type from the package json-autotype
    instance Out Type
    
    -- These are missing Uniplate instances...
    {-
    instance Biplate (Set a) a where
      biplate s = (Set.toList s, Set.fromList)
    
    instance Biplate (HashMap k v) v where
      biplate m = (Hash.elems m, Hash.fromList . zip (Hash.keys m))
     -}
    
    instance Uniplate Type where
      uniplate (TUnion s) = (Set.toList s, TUnion .        Set.fromList                     )
      uniplate (TObj   d) = (Hash.elems m, TObj   . Dict . Hash.fromList . zip (Hash.keys m))
        where
          m = unDict d
      uniplate (TArray t) = ([t],          TArray . head  )
      uniplate s          = ([],           const s        )
    

    Found in Data.Aeson.AutoType.Extract from the package json-autotype
                                   then emptyType
                                   else foldl1' unifyTypes arrayElts
    
    -- | Smart constructor for union types.
    union ::  Set Type -> Type
    union = simplifyUnion . TUnion
    
    -- | Simplify TUnion's so there is no TUnion directly inside TUnion.
    -- If there is only one element of the set, then return this single
    -- element as a type.
    simplifyUnion :: Type -> Type
    simplifyUnion (TUnion s) | Set.size s == 1 = head $ Set.toList s
    simplifyUnion (TUnion s)                   = TUnion $ Set.unions $ map elements $ Set.toList s
      where
        elements (TUnion elems) = elems
        elements sing           = Set.singleton sing
    simplifyUnion unexpected                   = error ("simplifyUnion: unexpected argument " ++ show unexpected)
    

    Found in Data.Aeson.AutoType.Extract from the package json-autotype
                                   then emptyType
                                   else foldl1' unifyTypes arrayElts
    
    -- | Smart constructor for union types.
    union ::  Set Type -> Type
    union = simplifyUnion . TUnion
    
    -- | Simplify TUnion's so there is no TUnion directly inside TUnion.
    -- If there is only one element of the set, then return this single
    -- element as a type.
    simplifyUnion :: Type -> Type
    simplifyUnion (TUnion s) | Set.size s == 1 = head $ Set.toList s
    simplifyUnion (TUnion s)                   = TUnion $ Set.unions $ map elements $ Set.toList s
      where
        elements (TUnion elems) = elems
        elements sing           = Set.singleton sing
    simplifyUnion unexpected                   = error ("simplifyUnion: unexpected argument " ++ show unexpected)
    

    Found in Data.Aeson.AutoType.Extract from the package json-autotype
    valueTypeSize (String _) = 1
    valueTypeSize (Array  a) = (1+) . V.foldl' max 0 $ V.map valueTypeSize a
    valueTypeSize (Object o) = (1+) . sum . map valueTypeSize . Map.elems $ o
    
    -- | Compute total depth of the value.
    -- For:
    -- * simple types it is 1
    -- * for either Array or Object, it is 1 + maximum of depths of their members
    valueDepth :: Value -> Int
    valueDepth  Null      = 1
    valueDepth (Bool   _) = 1
    valueDepth (Number _) = 1
    valueDepth (String _) = 1
    valueDepth (Array  a) = (1+) . V.foldl' max 0 $ V.map valueDepth a
    valueDepth (Object o) = (1+) . maximum . (0:) . map valueDepth . Map.elems $ o
    
    -- | Extract @Type@ from the JSON @Value@.
    -- Unifying types of array elements, if necessary.
    extractType                             :: Value -> Type
    extractType (Object o)                   = TObj $ Dict $ Map.map extractType o
    

    Found in Data.Aeson.AutoType.Extract from the package json-autotype
    valueSize (Object o) = (1+) . sum . map valueSize . Map.elems $ o
    
    -- | Compute total size of the type of the @Value@.
    -- For:
    -- * simple types it is always 1,
    -- * for arrays it is just 1+_maximum_ size of the (single) element type,
    -- * for objects it is _sum_ of the sizes of fields (since each field type
    --   is assumed to be different.)
    valueTypeSize :: Value -> Int
    valueTypeSize  Null      = 1
    valueTypeSize (Bool   _) = 1
    valueTypeSize (Number _) = 1
    valueTypeSize (String _) = 1
    valueTypeSize (Array  a) = (1+) . V.foldl' max 0 $ V.map valueTypeSize a
    valueTypeSize (Object o) = (1+) . sum . map valueTypeSize . Map.elems $ o
    
    -- | Compute total depth of the value.
    -- For:
    -- * simple types it is 1
    -- * for either Array or Object, it is 1 + maximum of depths of their members
    

    Found in Data.Aeson.AutoType.Extract from the package json-autotype
    import           Data.List                       (foldl1')
    
    --import           Debug.Trace
    
    -- | Compute total number of nodes (and leaves) within the value tree.
    -- Each simple JavaScript type (including String) is counted as of size 1,
    -- whereas both Array or object types are counted as 1+sum of the sizes
    -- of their member values.
    valueSize :: Value -> Int
    valueSize  Null      = 1
    valueSize (Bool   _) = 1
    valueSize (Number _) = 1
    valueSize (String _) = 1
    valueSize (Array  a) = V.foldl' (+) 1 $ V.map valueSize a
    valueSize (Object o) = (1+) . sum . map valueSize . Map.elems $ o
    
    -- | Compute total size of the type of the @Value@.
    -- For:
    -- * simple types it is always 1,
    -- * for arrays it is just 1+_maximum_ size of the (single) element type,
    

    Found in Data.Aeson.AutoType.Split from the package json-autotype
    -- | Computes all type labels referenced by a given type.
    allLabels :: Type -> [Text]
    allLabels = flip go []
      where
        go (TLabel l) ls = l:ls
        go (TArray t) ls = go t ls
        go (TUnion u) ls = Set.foldr go ls          u
        go (TObj   o) ls = Map.foldr go ls $ unDict o
        go _other     ls = ls
    
    -- * Finding candidates for extra unifications
    -- | For a given splitted types, it returns candidates for extra
    -- unifications.
    unificationCandidates :: Map.HashMap t Type -> [[t]]
    unificationCandidates = Map.elems             .
                            Map.filter candidates .
                            Map.fromListWith (++) .
                            concatMap entry       .
                            Map.toList
      where
    

    Found in Data.Aeson.AutoType.Type from the package json-autotype
    -- | Is the top-level constructor a TUnion?
    isUnion           :: Type -> Bool
    isUnion (TUnion _) = True
    isUnion _          = False
    
    -- | Is the top-level constructor a TArray?
    -- | Check if the given type has non-top TObj.
    isArray           :: Type -> Bool
    isArray (TArray _) = True
    isArray _          = False
    
    -- | Check if the given type has non-top TObj.
    hasNonTopTObj         :: Type -> Bool
    hasNonTopTObj (TObj o) = any hasTObj $ Hash.elems $ unDict o
    hasNonTopTObj _        = False
    
    -- | Check if the given type has TObj on top or within array..
    hasTObj           :: Type -> Bool
    hasTObj (TObj   _) = True
    

    Found in Data.Aeson.AutoType.Type from the package json-autotype
    emptyType = TUnion Set.empty
    
    -- | Lookup the Type within the dictionary.
    get :: Text -> Dict -> Type
    get key = Hash.lookupDefault TNull key . unDict
    
    -- $derive makeUniplateDirect ''Type
    
    -- | Size of the `Type` term.
    typeSize           :: Type -> Int
    typeSize TNull      = 1
    typeSize TBool      = 1
    typeSize TNum       = 1
    typeSize TString    = 1
    typeSize (TObj   o) = (1+) . sum     . map typeSize . Hash.elems . unDict $ o
    typeSize (TArray a) = 1 + typeSize a
    typeSize (TUnion u) = (1+) . sum . (0:) . map typeSize . Set.toList $ u
    typeSize (TLabel _) = error "Don't know how to compute typeSize of TLabel."
    
    -- | Check if this is nullable (Maybe) type, or not.
    

    Found in Data.Aeson.AutoType.Type from the package json-autotype
    instance Out Type
    
    -- These are missing Uniplate instances...
    {-
    instance Biplate (Set a) a where
      biplate s = (Set.toList s, Set.fromList)
    
    instance Biplate (HashMap k v) v where
      biplate m = (Hash.elems m, Hash.fromList . zip (Hash.keys m))
     -}
    
    instance Uniplate Type where
      uniplate (TUnion s) = (Set.toList s, TUnion .        Set.fromList                     )
      uniplate (TObj   d) = (Hash.elems m, TObj   . Dict . Hash.fromList . zip (Hash.keys m))
        where
          m = unDict d
      uniplate (TArray t) = ([t],          TArray . head  )
      uniplate s          = ([],           const s        )
    

    Found in Data.Aeson.AutoType.Type from the package json-autotype
    -- | Is the top-level constructor a TUnion?
    isUnion           :: Type -> Bool
    isUnion (TUnion _) = True
    isUnion _          = False
    
    -- | Is the top-level constructor a TArray?
    -- | Check if the given type has non-top TObj.
    isArray           :: Type -> Bool
    isArray (TArray _) = True
    isArray _          = False
    
    -- | Check if the given type has non-top TObj.
    hasNonTopTObj         :: Type -> Bool
    hasNonTopTObj (TObj o) = any hasTObj $ Hash.elems $ unDict o
    hasNonTopTObj _        = False
    
    -- | Check if the given type has TObj on top or within array..
    hasTObj           :: Type -> Bool
    hasTObj (TObj   _) = True
    

    Found in Data.Aeson.AutoType.Type from the package json-autotype
    emptyType = TUnion Set.empty
    
    -- | Lookup the Type within the dictionary.
    get :: Text -> Dict -> Type
    get key = Hash.lookupDefault TNull key . unDict
    
    -- $derive makeUniplateDirect ''Type
    
    -- | Size of the `Type` term.
    typeSize           :: Type -> Int
    typeSize TNull      = 1
    typeSize TBool      = 1
    typeSize TNum       = 1
    typeSize TString    = 1
    typeSize (TObj   o) = (1+) . sum     . map typeSize . Hash.elems . unDict $ o
    typeSize (TArray a) = 1 + typeSize a
    typeSize (TUnion u) = (1+) . sum . (0:) . map typeSize . Set.toList $ u
    typeSize (TLabel _) = error "Don't know how to compute typeSize of TLabel."
    
    -- | Check if this is nullable (Maybe) type, or not.
    

    Found in Data.Aeson.AutoType.Type from the package json-autotype
    instance Out Type
    
    -- These are missing Uniplate instances...
    {-
    instance Biplate (Set a) a where
      biplate s = (Set.toList s, Set.fromList)
    
    instance Biplate (HashMap k v) v where
      biplate m = (Hash.elems m, Hash.fromList . zip (Hash.keys m))
     -}
    
    instance Uniplate Type where
      uniplate (TUnion s) = (Set.toList s, TUnion .        Set.fromList                     )
      uniplate (TObj   d) = (Hash.elems m, TObj   . Dict . Hash.fromList . zip (Hash.keys m))
        where
          m = unDict d
      uniplate (TArray t) = ([t],          TArray . head  )
      uniplate s          = ([],           const s        )
    

    Found in Data.Aeson.AutoType.Split from the package json-autotype
    -- | Computes all type labels referenced by a given type.
    allLabels :: Type -> [Text]
    allLabels = flip go []
      where
        go (TLabel l) ls = l:ls
        go (TArray t) ls = go t ls
        go (TUnion u) ls = Set.foldr go ls          u
        go (TObj   o) ls = Map.foldr go ls $ unDict o
        go _other     ls = ls
    
    -- * Finding candidates for extra unifications
    -- | For a given splitted types, it returns candidates for extra
    -- unifications.
    unificationCandidates :: Map.HashMap t Type -> [[t]]
    unificationCandidates = Map.elems             .
                            Map.filter candidates .
                            Map.fromListWith (++) .
                            concatMap entry       .
                            Map.toList
      where
    

    Found in Data.Aeson.AutoType.Extract from the package json-autotype
                                   then emptyType
                                   else foldl1' unifyTypes arrayElts
    
    -- | Smart constructor for union types.
    union ::  Set Type -> Type
    union = simplifyUnion . TUnion
    
    -- | Simplify TUnion's so there is no TUnion directly inside TUnion.
    -- If there is only one element of the set, then return this single
    -- element as a type.
    simplifyUnion :: Type -> Type
    simplifyUnion (TUnion s) | Set.size s == 1 = head $ Set.toList s
    simplifyUnion (TUnion s)                   = TUnion $ Set.unions $ map elements $ Set.toList s
      where
        elements (TUnion elems) = elems
        elements sing           = Set.singleton sing
    simplifyUnion unexpected                   = error ("simplifyUnion: unexpected argument " ++ show unexpected)
    

    Found in Data.Aeson.AutoType.Extract from the package json-autotype
                                   then emptyType
                                   else foldl1' unifyTypes arrayElts
    
    -- | Smart constructor for union types.
    union ::  Set Type -> Type
    union = simplifyUnion . TUnion
    
    -- | Simplify TUnion's so there is no TUnion directly inside TUnion.
    -- If there is only one element of the set, then return this single
    -- element as a type.
    simplifyUnion :: Type -> Type
    simplifyUnion (TUnion s) | Set.size s == 1 = head $ Set.toList s
    simplifyUnion (TUnion s)                   = TUnion $ Set.unions $ map elements $ Set.toList s
      where
        elements (TUnion elems) = elems
        elements sing           = Set.singleton sing
    simplifyUnion unexpected                   = error ("simplifyUnion: unexpected argument " ++ show unexpected)
    

    Found in Data.Aeson.AutoType.Extract from the package json-autotype
    valueTypeSize (String _) = 1
    valueTypeSize (Array  a) = (1+) . V.foldl' max 0 $ V.map valueTypeSize a
    valueTypeSize (Object o) = (1+) . sum . map valueTypeSize . Map.elems $ o
    
    -- | Compute total depth of the value.
    -- For:
    -- * simple types it is 1
    -- * for either Array or Object, it is 1 + maximum of depths of their members
    valueDepth :: Value -> Int
    valueDepth  Null      = 1
    valueDepth (Bool   _) = 1
    valueDepth (Number _) = 1
    valueDepth (String _) = 1
    valueDepth (Array  a) = (1+) . V.foldl' max 0 $ V.map valueDepth a
    valueDepth (Object o) = (1+) . maximum . (0:) . map valueDepth . Map.elems $ o
    
    -- | Extract @Type@ from the JSON @Value@.
    -- Unifying types of array elements, if necessary.
    extractType                             :: Value -> Type
    extractType (Object o)                   = TObj $ Dict $ Map.map extractType o
    

    Found in Data.Aeson.AutoType.Extract from the package json-autotype
    valueSize (Object o) = (1+) . sum . map valueSize . Map.elems $ o
    
    -- | Compute total size of the type of the @Value@.
    -- For:
    -- * simple types it is always 1,
    -- * for arrays it is just 1+_maximum_ size of the (single) element type,
    -- * for objects it is _sum_ of the sizes of fields (since each field type
    --   is assumed to be different.)
    valueTypeSize :: Value -> Int
    valueTypeSize  Null      = 1
    valueTypeSize (Bool   _) = 1
    valueTypeSize (Number _) = 1
    valueTypeSize (String _) = 1
    valueTypeSize (Array  a) = (1+) . V.foldl' max 0 $ V.map valueTypeSize a
    valueTypeSize (Object o) = (1+) . sum . map valueTypeSize . Map.elems $ o
    
    -- | Compute total depth of the value.
    -- For:
    -- * simple types it is 1
    -- * for either Array or Object, it is 1 + maximum of depths of their members
    

    Found in Data.Aeson.AutoType.Extract from the package json-autotype
    import           Data.List                       (foldl1')
    
    --import           Debug.Trace
    
    -- | Compute total number of nodes (and leaves) within the value tree.
    -- Each simple JavaScript type (including String) is counted as of size 1,
    -- whereas both Array or object types are counted as 1+sum of the sizes
    -- of their member values.
    valueSize :: Value -> Int
    valueSize  Null      = 1
    valueSize (Bool   _) = 1
    valueSize (Number _) = 1
    valueSize (String _) = 1
    valueSize (Array  a) = V.foldl' (+) 1 $ V.map valueSize a
    valueSize (Object o) = (1+) . sum . map valueSize . Map.elems $ o
    
    -- | Compute total size of the type of the @Value@.
    -- For:
    -- * simple types it is always 1,
    -- * for arrays it is just 1+_maximum_ size of the (single) element type,
    

    Found in Data.Aeson.AutoType.Type from the package json-autotype
    -- | Is the top-level constructor a TUnion?
    isUnion           :: Type -> Bool
    isUnion (TUnion _) = True
    isUnion _          = False
    
    -- | Is the top-level constructor a TArray?
    -- | Check if the given type has non-top TObj.
    isArray           :: Type -> Bool
    isArray (TArray _) = True
    isArray _          = False
    
    -- | Check if the given type has non-top TObj.
    hasNonTopTObj         :: Type -> Bool
    hasNonTopTObj (TObj o) = any hasTObj $ Hash.elems $ unDict o
    hasNonTopTObj _        = False
    
    -- | Check if the given type has TObj on top or within array..
    hasTObj           :: Type -> Bool
    hasTObj (TObj   _) = True
    

    Found in Data.Aeson.AutoType.Type from the package json-autotype
    emptyType = TUnion Set.empty
    
    -- | Lookup the Type within the dictionary.
    get :: Text -> Dict -> Type
    get key = Hash.lookupDefault TNull key . unDict
    
    -- $derive makeUniplateDirect ''Type
    
    -- | Size of the `Type` term.
    typeSize           :: Type -> Int
    typeSize TNull      = 1
    typeSize TBool      = 1
    typeSize TNum       = 1
    typeSize TString    = 1
    typeSize (TObj   o) = (1+) . sum     . map typeSize . Hash.elems . unDict $ o
    typeSize (TArray a) = 1 + typeSize a
    typeSize (TUnion u) = (1+) . sum . (0:) . map typeSize . Set.toList $ u
    typeSize (TLabel _) = error "Don't know how to compute typeSize of TLabel."
    
    -- | Check if this is nullable (Maybe) type, or not.
    

    Found in Data.Aeson.AutoType.Type from the package json-autotype
    instance Out Type
    
    -- These are missing Uniplate instances...
    {-
    instance Biplate (Set a) a where
      biplate s = (Set.toList s, Set.fromList)
    
    instance Biplate (HashMap k v) v where
      biplate m = (Hash.elems m, Hash.fromList . zip (Hash.keys m))
     -}
    
    instance Uniplate Type where
      uniplate (TUnion s) = (Set.toList s, TUnion .        Set.fromList                     )
      uniplate (TObj   d) = (Hash.elems m, TObj   . Dict . Hash.fromList . zip (Hash.keys m))
        where
          m = unDict d
      uniplate (TArray t) = ([t],          TArray . head  )
      uniplate s          = ([],           const s        )
    

    Found in Data.Aeson.AutoType.Extract from the package json-autotype
                                   then emptyType
                                   else foldl1' unifyTypes arrayElts
    
    -- | Smart constructor for union types.
    union ::  Set Type -> Type
    union = simplifyUnion . TUnion
    
    -- | Simplify TUnion's so there is no TUnion directly inside TUnion.
    -- If there is only one element of the set, then return this single
    -- element as a type.
    simplifyUnion :: Type -> Type
    simplifyUnion (TUnion s) | Set.size s == 1 = head $ Set.toList s
    simplifyUnion (TUnion s)                   = TUnion $ Set.unions $ map elements $ Set.toList s
      where
        elements (TUnion elems) = elems
        elements sing           = Set.singleton sing
    simplifyUnion unexpected                   = error ("simplifyUnion: unexpected argument " ++ show unexpected)
    

    Found in Data.Aeson.AutoType.Extract from the package json-autotype
                                   then emptyType
                                   else foldl1' unifyTypes arrayElts
    
    -- | Smart constructor for union types.
    union ::  Set Type -> Type
    union = simplifyUnion . TUnion
    
    -- | Simplify TUnion's so there is no TUnion directly inside TUnion.
    -- If there is only one element of the set, then return this single
    -- element as a type.
    simplifyUnion :: Type -> Type
    simplifyUnion (TUnion s) | Set.size s == 1 = head $ Set.toList s
    simplifyUnion (TUnion s)                   = TUnion $ Set.unions $ map elements $ Set.toList s
      where
        elements (TUnion elems) = elems
        elements sing           = Set.singleton sing
    simplifyUnion unexpected                   = error ("simplifyUnion: unexpected argument " ++ show unexpected)
    

    Found in Data.Aeson.AutoType.Extract from the package json-autotype
    valueTypeSize (String _) = 1
    valueTypeSize (Array  a) = (1+) . V.foldl' max 0 $ V.map valueTypeSize a
    valueTypeSize (Object o) = (1+) . sum . map valueTypeSize . Map.elems $ o
    
    -- | Compute total depth of the value.
    -- For:
    -- * simple types it is 1
    -- * for either Array or Object, it is 1 + maximum of depths of their members
    valueDepth :: Value -> Int
    valueDepth  Null      = 1
    valueDepth (Bool   _) = 1
    valueDepth (Number _) = 1
    valueDepth (String _) = 1
    valueDepth (Array  a) = (1+) . V.foldl' max 0 $ V.map valueDepth a
    valueDepth (Object o) = (1+) . maximum . (0:) . map valueDepth . Map.elems $ o
    
    -- | Extract @Type@ from the JSON @Value@.
    -- Unifying types of array elements, if necessary.
    extractType                             :: Value -> Type
    extractType (Object o)                   = TObj $ Dict $ Map.map extractType o
    

    Found in Data.Aeson.AutoType.Extract from the package json-autotype
    valueSize (Object o) = (1+) . sum . map valueSize . Map.elems $ o
    
    -- | Compute total size of the type of the @Value@.
    -- For:
    -- * simple types it is always 1,
    -- * for arrays it is just 1+_maximum_ size of the (single) element type,
    -- * for objects it is _sum_ of the sizes of fields (since each field type
    --   is assumed to be different.)
    valueTypeSize :: Value -> Int
    valueTypeSize  Null      = 1
    valueTypeSize (Bool   _) = 1
    valueTypeSize (Number _) = 1
    valueTypeSize (String _) = 1
    valueTypeSize (Array  a) = (1+) . V.foldl' max 0 $ V.map valueTypeSize a
    valueTypeSize (Object o) = (1+) . sum . map valueTypeSize . Map.elems $ o
    
    -- | Compute total depth of the value.
    -- For:
    -- * simple types it is 1
    -- * for either Array or Object, it is 1 + maximum of depths of their members
    

    Found in Data.Aeson.AutoType.Extract from the package json-autotype
    import           Data.List                       (foldl1')
    
    --import           Debug.Trace
    
    -- | Compute total number of nodes (and leaves) within the value tree.
    -- Each simple JavaScript type (including String) is counted as of size 1,
    -- whereas both Array or object types are counted as 1+sum of the sizes
    -- of their member values.
    valueSize :: Value -> Int
    valueSize  Null      = 1
    valueSize (Bool   _) = 1
    valueSize (Number _) = 1
    valueSize (String _) = 1
    valueSize (Array  a) = V.foldl' (+) 1 $ V.map valueSize a
    valueSize (Object o) = (1+) . sum . map valueSize . Map.elems $ o
    
    -- | Compute total size of the type of the @Value@.
    -- For:
    -- * simple types it is always 1,
    -- * for arrays it is just 1+_maximum_ size of the (single) element type,
    

    Found in Data.Aeson.AutoType.Split from the package json-autotype
    -- | Computes all type labels referenced by a given type.
    allLabels :: Type -> [Text]
    allLabels = flip go []
      where
        go (TLabel l) ls = l:ls
        go (TArray t) ls = go t ls
        go (TUnion u) ls = Set.foldr go ls          u
        go (TObj   o) ls = Map.foldr go ls $ unDict o
        go _other     ls = ls
    
    -- * Finding candidates for extra unifications
    -- | For a given splitted types, it returns candidates for extra
    -- unifications.
    unificationCandidates :: Map.HashMap t Type -> [[t]]
    unificationCandidates = Map.elems             .
                            Map.filter candidates .
                            Map.fromListWith (++) .
                            concatMap entry       .
                            Map.toList
      where
    

    Found in Data.Aeson.AutoType.Type from the package json-autotype
    -- | Is the top-level constructor a TUnion?
    isUnion           :: Type -> Bool
    isUnion (TUnion _) = True
    isUnion _          = False
    
    -- | Is the top-level constructor a TArray?
    -- | Check if the given type has non-top TObj.
    isArray           :: Type -> Bool
    isArray (TArray _) = True
    isArray _          = False
    
    -- | Check if the given type has non-top TObj.
    hasNonTopTObj         :: Type -> Bool
    hasNonTopTObj (TObj o) = any hasTObj $ Hash.elems $ unDict o
    hasNonTopTObj _        = False
    
    -- | Check if the given type has TObj on top or within array..
    hasTObj           :: Type -> Bool
    hasTObj (TObj   _) = True
    

    Found in Data.Aeson.AutoType.Type from the package json-autotype
    emptyType = TUnion Set.empty
    
    -- | Lookup the Type within the dictionary.
    get :: Text -> Dict -> Type
    get key = Hash.lookupDefault TNull key . unDict
    
    -- $derive makeUniplateDirect ''Type
    
    -- | Size of the `Type` term.
    typeSize           :: Type -> Int
    typeSize TNull      = 1
    typeSize TBool      = 1
    typeSize TNum       = 1
    typeSize TString    = 1
    typeSize (TObj   o) = (1+) . sum     . map typeSize . Hash.elems . unDict $ o
    typeSize (TArray a) = 1 + typeSize a
    typeSize (TUnion u) = (1+) . sum . (0:) . map typeSize . Set.toList $ u
    typeSize (TLabel _) = error "Don't know how to compute typeSize of TLabel."
    
    -- | Check if this is nullable (Maybe) type, or not.
    

    Found in Data.Aeson.AutoType.Type from the package json-autotype
    instance Out Type
    
    -- These are missing Uniplate instances...
    {-
    instance Biplate (Set a) a where
      biplate s = (Set.toList s, Set.fromList)
    
    instance Biplate (HashMap k v) v where
      biplate m = (Hash.elems m, Hash.fromList . zip (Hash.keys m))
     -}
    
    instance Uniplate Type where
      uniplate (TUnion s) = (Set.toList s, TUnion .        Set.fromList                     )
      uniplate (TObj   d) = (Hash.elems m, TObj   . Dict . Hash.fromList . zip (Hash.keys m))
        where
          m = unDict d
      uniplate (TArray t) = ([t],          TArray . head  )
      uniplate s          = ([],           const s        )
    

    Found in Data.Aeson.AutoType.Extract from the package json-autotype
                                   then emptyType
                                   else foldl1' unifyTypes arrayElts
    
    -- | Smart constructor for union types.
    union ::  Set Type -> Type
    union = simplifyUnion . TUnion
    
    -- | Simplify TUnion's so there is no TUnion directly inside TUnion.
    -- If there is only one element of the set, then return this single
    -- element as a type.
    simplifyUnion :: Type -> Type
    simplifyUnion (TUnion s) | Set.size s == 1 = head $ Set.toList s
    simplifyUnion (TUnion s)                   = TUnion $ Set.unions $ map elements $ Set.toList s
      where
        elements (TUnion elems) = elems
        elements sing           = Set.singleton sing
    simplifyUnion unexpected                   = error ("simplifyUnion: unexpected argument " ++ show unexpected)
    

    Found in Data.Aeson.AutoType.Extract from the package json-autotype
                                   then emptyType
                                   else foldl1' unifyTypes arrayElts
    
    -- | Smart constructor for union types.
    union ::  Set Type -> Type
    union = simplifyUnion . TUnion
    
    -- | Simplify TUnion's so there is no TUnion directly inside TUnion.
    -- If there is only one element of the set, then return this single
    -- element as a type.
    simplifyUnion :: Type -> Type
    simplifyUnion (TUnion s) | Set.size s == 1 = head $ Set.toList s
    simplifyUnion (TUnion s)                   = TUnion $ Set.unions $ map elements $ Set.toList s
      where
        elements (TUnion elems) = elems
        elements sing           = Set.singleton sing
    simplifyUnion unexpected                   = error ("simplifyUnion: unexpected argument " ++ show unexpected)
    

    Found in Data.Aeson.AutoType.Extract from the package json-autotype
    valueTypeSize (String _) = 1
    valueTypeSize (Array  a) = (1+) . V.foldl' max 0 $ V.map valueTypeSize a
    valueTypeSize (Object o) = (1+) . sum . map valueTypeSize . Map.elems $ o
    
    -- | Compute total depth of the value.
    -- For:
    -- * simple types it is 1
    -- * for either Array or Object, it is 1 + maximum of depths of their members
    valueDepth :: Value -> Int
    valueDepth  Null      = 1
    valueDepth (Bool   _) = 1
    valueDepth (Number _) = 1
    valueDepth (String _) = 1
    valueDepth (Array  a) = (1+) . V.foldl' max 0 $ V.map valueDepth a
    valueDepth (Object o) = (1+) . maximum . (0:) . map valueDepth . Map.elems $ o
    
    -- | Extract @Type@ from the JSON @Value@.
    -- Unifying types of array elements, if necessary.
    extractType                             :: Value -> Type
    extractType (Object o)                   = TObj $ Dict $ Map.map extractType o
    

    Found in Data.Aeson.AutoType.Extract from the package json-autotype
    valueSize (Object o) = (1+) . sum . map valueSize . Map.elems $ o
    
    -- | Compute total size of the type of the @Value@.
    -- For:
    -- * simple types it is always 1,
    -- * for arrays it is just 1+_maximum_ size of the (single) element type,
    -- * for objects it is _sum_ of the sizes of fields (since each field type
    --   is assumed to be different.)
    valueTypeSize :: Value -> Int
    valueTypeSize  Null      = 1
    valueTypeSize (Bool   _) = 1
    valueTypeSize (Number _) = 1
    valueTypeSize (String _) = 1
    valueTypeSize (Array  a) = (1+) . V.foldl' max 0 $ V.map valueTypeSize a
    valueTypeSize (Object o) = (1+) . sum . map valueTypeSize . Map.elems $ o
    
    -- | Compute total depth of the value.
    -- For:
    -- * simple types it is 1
    -- * for either Array or Object, it is 1 + maximum of depths of their members
    

    Found in Data.Aeson.AutoType.Extract from the package json-autotype
    import           Data.List                       (foldl1')
    
    --import           Debug.Trace
    
    -- | Compute total number of nodes (and leaves) within the value tree.
    -- Each simple JavaScript type (including String) is counted as of size 1,
    -- whereas both Array or object types are counted as 1+sum of the sizes
    -- of their member values.
    valueSize :: Value -> Int
    valueSize  Null      = 1
    valueSize (Bool   _) = 1
    valueSize (Number _) = 1
    valueSize (String _) = 1
    valueSize (Array  a) = V.foldl' (+) 1 $ V.map valueSize a
    valueSize (Object o) = (1+) . sum . map valueSize . Map.elems $ o
    
    -- | Compute total size of the type of the @Value@.
    -- For:
    -- * simple types it is always 1,
    -- * for arrays it is just 1+_maximum_ size of the (single) element type,
    

    Found in Data.Aeson.AutoType.Split from the package json-autotype
    -- | Computes all type labels referenced by a given type.
    allLabels :: Type -> [Text]
    allLabels = flip go []
      where
        go (TLabel l) ls = l:ls
        go (TArray t) ls = go t ls
        go (TUnion u) ls = Set.foldr go ls          u
        go (TObj   o) ls = Map.foldr go ls $ unDict o
        go _other     ls = ls
    
    -- * Finding candidates for extra unifications
    -- | For a given splitted types, it returns candidates for extra
    -- unifications.
    unificationCandidates :: Map.HashMap t Type -> [[t]]
    unificationCandidates = Map.elems             .
                            Map.filter candidates .
                            Map.fromListWith (++) .
                            concatMap entry       .
                            Map.toList
      where
    

    Found in Data.JSON.Schema.Types from the package json-schema
    instance JSONSchema a => JSONSchema (Maybe a) where
      schema p = Choice [Object [Field "Just" True $ schema $ fmap fromJust p], Object [Field "Nothing" True (Constant Aeson.Null)]]
    
    instance JSONSchema a => JSONSchema [a] where
      schema = Array unboundedLength False . schema . fmap head
    
    instance JSONSchema a => JSONSchema (Vector a) where
      schema = Array unboundedLength False . schema . fmap V.head
    
    instance (IsString k, JSONSchema v) => JSONSchema (M.Map k v) where
      schema = Map . schema . fmap (head . M.elems)
    
    instance (IsString k, JSONSchema v) => JSONSchema (H.HashMap k v) where
      schema = Map . schema . fmap (head . H.elems)
    
    instance JSONSchema UTCTime where
      schema _ = Value LengthBound { lowerLength = Just 20, upperLength = Just 33 }
    
    instance JSONSchema a => JSONSchema (S.Set a) where
    

    Found in Data.JSON.Schema.Types from the package json-schema
    instance JSONSchema L.Text where
      schema _ = Value unboundedLength
    
    instance JSONSchema a => JSONSchema (Maybe a) where
      schema p = Choice [Object [Field "Just" True $ schema $ fmap fromJust p], Object [Field "Nothing" True (Constant Aeson.Null)]]
    
    instance JSONSchema a => JSONSchema [a] where
      schema = Array unboundedLength False . schema . fmap head
    
    instance JSONSchema a => JSONSchema (Vector a) where
      schema = Array unboundedLength False . schema . fmap V.head
    
    instance (IsString k, JSONSchema v) => JSONSchema (M.Map k v) where
      schema = Map . schema . fmap (head . M.elems)
    
    instance (IsString k, JSONSchema v) => JSONSchema (H.HashMap k v) where
      schema = Map . schema . fmap (head . H.elems)
    
    instance JSONSchema UTCTime where
    

    Found in Math.MFSolve from the package mfsolve
    getKnown :: (Eq v, Hashable v) => v -> Dependencies v n -> Either [v] n
    getKnown var (Dependencies _ lin _ _ _) =
      case M.lookup var lin of
        Nothing -> Left  []
        Just (LinExpr a []) ->
          Right a
        Just (LinExpr _ v) ->
          Left $ map fst v
    
    -- | Return all nonlinear equations @e_i@, where @e_i = 0@.
    nonlinearEqs :: (Ord n, Ord v, Floating n) => Dependencies v n -> [Expr v n]
    nonlinearEqs  (Dependencies _ _ trig trig2 nl) =
      map trigToExpr trig ++
      map (\(v, e) -> makeVariable v - e) 
      (concatMap M.toList (M.elems trig2)) ++
      nl
      
    -- | Show all variables and equations.  Useful in combination with `execSolver`.
    showVars :: (Show n, Show v, Ord n, Ord v, Floating n) => Either (DepError v n) (Dependencies v n) -> IO ()
    showVars (Left e) = print e
    

    Found in Math.MFSolve from the package mfsolve
        (Dependencies vdep' lin' trig trig2 nonlin,
         [LinearE lt - makeVariable v])
      | Just vars <- M.lookup v vdep,
        (v2:_) <- H.toList vars =
          -- v is independend, and appears in a linear equation
          case deleteDep vdep lin v2 of
           Nothing ->
             error $ "Internal error: found empty dependency on " ++ show v2
           Just (vdep', lin', lt) ->
             -- rearrange the deleted equation in terms of v
             let lt2 = snd $ reArrange v2 lt v
                 -- substitute v in all equations
                 (vdep'', lin'') = substDep vdep' lin' v lt2 False
                 trig' = map trigToExpr trig
                 trig2' = concatMap trig2ToExpr $ M.elems trig2
                 deps = Dependencies vdep'' lin'' [] M.empty []
                 e = [LinearE lt2 - makeVariable v]
              -- use addEq0 since substitution is unnecessary
             in case foldM (flip addEq0 zeroExpr)
                     deps $
    

    Found in Math.MFSolve from the package mfsolve
    -- adding a constant equation
    addEq0 _ e (ConstE c) =
      Left $ if abs c < eps
             then RedundantEq e
             else InconsistentEq c e
      where eps = 0.0001
    
    -- adding a linear equation
    addEq0 (Dependencies vdep lin trig trig2 nonlin) _ (Expr lt [] []) =
      let (v, _, lt2) = splitMax lt
          (vdep', lin') = substDep vdep lin v lt2 True
          
          -- Add nonlinear equations again to the system.
          trig' = map trigToExpr trig
          trig2' = concatMap trig2ToExpr $ M.elems trig2
      in addEqs (Dependencies vdep' lin' [] M.empty []) (trig'++trig2'++nonlin)
    
    -- adding a sine equation
    addEq0 deps@(Dependencies vdep lin trig trig2 nl) orig
      (Expr (LinExpr c lt) [(theta, [(alpha, LConst n)])] []) =
    

    Found in Data.HashMap.Monoidal from the package monoidal-containers
    lookupM :: (Eq k, Hashable k, Monoid v) => k -> MonoidalHashMap k v -> v
    lookupM k = fromMaybe mempty . M.lookup k . unpack
    {-# INLINE lookupM #-}
    
    -- | /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 :: (Eq k, Hashable k) => k -> MonoidalHashMap k a -> MonoidalHashMap k a
    delete k = _Wrapping' MonoidalHashMap %~ M.delete k
    {-# INLINE delete #-}
    
    -- | /O(n)/.
    -- Return a list of this map's values. The list is produced lazily.
    elems :: MonoidalHashMap k a -> [a]
    elems = M.elems . unpack
    {-# INLINE elems #-}
    
    -- | /O(n)/. Return all keys of the map in ascending order. Subject to list
    -- fusion.
    keys :: MonoidalHashMap k a -> [k]
    keys = M.keys . unpack
    

    Found in Data.HashMap.Monoidal from the package monoidal-containers
    -- or mempty if this map contains no mapping for the key.
    lookupM :: (Eq k, Hashable k, Monoid v) => k -> MonoidalHashMap k v -> v
    lookupM k = fromMaybe mempty . M.lookup k . unpack
    {-# INLINE lookupM #-}
    
    -- | /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 :: (Eq k, Hashable k) => k -> MonoidalHashMap k a -> MonoidalHashMap k a
    delete k = _Wrapping' MonoidalHashMap %~ M.delete k
    {-# INLINE delete #-}
    
    -- | /O(n)/.
    -- Return a list of this map's values. The list is produced lazily.
    elems :: MonoidalHashMap k a -> [a]
    elems = M.elems . unpack
    {-# INLINE elems #-}
    
    -- | /O(n)/. Return all keys of the map in ascending order. Subject to list
    -- fusion.
    keys :: MonoidalHashMap k a -> [k]
    

    Found in Data.HashMap.Monoidal from the package monoidal-containers
    -- or mempty if this map contains no mapping for the key.
    lookupM :: (Eq k, Hashable k, Monoid v) => k -> MonoidalHashMap k v -> v
    lookupM k = fromMaybe mempty . M.lookup k . unpack
    {-# INLINE lookupM #-}
    
    -- | /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 :: (Eq k, Hashable k) => k -> MonoidalHashMap k a -> MonoidalHashMap k a
    delete k = _Wrapping' MonoidalHashMap %~ M.delete k
    {-# INLINE delete #-}
    
    -- | /O(n)/.
    -- Return a list of this map's values. The list is produced lazily.
    elems :: MonoidalHashMap k a -> [a]
    elems = M.elems . unpack
    {-# INLINE elems #-}
    
    -- | /O(n)/. Return all keys of the map in ascending order. Subject to list
    -- fusion.
    keys :: MonoidalHashMap k a -> [k]
    

    Found in Data.HashMap.Monoidal from the package monoidal-containers
    -- | /O(log n)/ Return the value to which the specified key is mapped,
    -- or mempty if this map contains no mapping for the key.
    lookupM :: (Eq k, Hashable k, Monoid v) => k -> MonoidalHashMap k v -> v
    lookupM k = fromMaybe mempty . M.lookup k . unpack
    {-# INLINE lookupM #-}
    
    -- | /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 :: (Eq k, Hashable k) => k -> MonoidalHashMap k a -> MonoidalHashMap k a
    delete k = _Wrapping' MonoidalHashMap %~ M.delete k
    {-# INLINE delete #-}
    
    -- | /O(n)/.
    -- Return a list of this map's values. The list is produced lazily.
    elems :: MonoidalHashMap k a -> [a]
    elems = M.elems . unpack
    {-# INLINE elems #-}
    
    -- | /O(n)/. Return all keys of the map in ascending order. Subject to list
    -- fusion.
    

    Found in Data.HashMap.Monoidal from the package monoidal-containers
    -- either the 'Newtype' or 'Wrapped' instances to manipulate the
    -- underlying 'Map'.
    
    module Data.HashMap.Monoidal
        ( MonoidalHashMap(..)
          -- * Often-needed functions
        , toList
        , fromList
        , singleton
        , size
        , member
        , notMember
        , lookup
        , lookupM
        , elems
        , keys
        , delete
        , mapKeys
        , modify
        , modifyDef
    

    Found in Relude.Extra.Map from the package relude
    {- | Converts the structure to the list of the keys.
    
    >>> keys (HashMap.fromList [('a', "xxx"), ('b', "yyy")])
    "ab"
    -}
    keys :: (IsList t, Item t ~ (a, b)) => t -> [a]
    keys = map fst . toList
    
    {- | Converts the structure to the list of the values.
    
    >>> elems (HashMap.fromList [('a', "xxx"), ('b', "yyy")])
    ["xxx","yyy"]
    -}
    elems :: (IsList t, Item t ~ (a, b)) => t -> [b]
    elems = map snd . toList
    

    Found in Relude.Extra.Map from the package relude
    {- | Converts the structure to the list of the keys.
    
    >>> keys (HashMap.fromList [('a', "xxx"), ('b', "yyy")])
    "ab"
    -}
    keys :: (IsList t, Item t ~ (a, b)) => t -> [a]
    keys = map fst . toList
    
    {- | Converts the structure to the list of the values.
    
    >>> elems (HashMap.fromList [('a', "xxx"), ('b', "yyy")])
    ["xxx","yyy"]
    -}
    elems :: (IsList t, Item t ~ (a, b)) => t -> [b]
    elems = map snd . toList
    

    Found in Relude.Extra.Map from the package relude
    {- | Contains implememtation of polymorhic type classes for things like 'Set'
    and 'Map'.
    -}
    
    module Relude.Extra.Map
           ( StaticMap (..)
           , DynamicMap (..)
           , (!?)
           , notMember
           , lookupDefault
    
             -- * To pairs
           , toPairs
           , keys
           , elems
           ) where
    
    import GHC.Exts (IsList (Item, toList))
    
    import Relude.Applicative (pure, (*>))
    

    Found in RIO.HashMap from the package rio
        -- * Folds
      , Data.HashMap.Strict.foldl'
      , Data.HashMap.Strict.foldlWithKey'
      , Data.HashMap.Strict.foldr
      , Data.HashMap.Strict.foldrWithKey
    
        -- * Filter
      , Data.HashMap.Strict.filter
      , Data.HashMap.Strict.filterWithKey
      , Data.HashMap.Strict.mapMaybe
      , Data.HashMap.Strict.mapMaybeWithKey
    
        -- * Conversions
      , Data.HashMap.Strict.keys
      , Data.HashMap.Strict.elems
    
        -- ** Lists
      , Data.HashMap.Strict.toList
      , Data.HashMap.Strict.fromList
      , Data.HashMap.Strict.fromListWith
    

    Found in Toml.Printer from the package tomland
        valText (Date d)    = timeText d
        valText (Array a)   = "[" <> Text.intercalate ", " (map valText a) <> "]"
    
        timeText :: DateTime -> Text
        timeText (Zoned z) = showText z
        timeText (Local l) = showText l
        timeText (Day d)   = showText d
        timeText (Hours h) = showText h
    
        showText :: Show a => a -> Text
        showText = Text.pack . show
    
    -- | Returns pretty formatted tables section of the 'TOML'.
    prettyTables :: Int -> Text -> PrefixMap TOML -> Text
    prettyTables i pref = Text.concat . map prettyTable . HashMap.elems
      where
        prettyTable :: PrefixTree TOML -> Text
        prettyTable (Leaf k toml) =
            let name = getPref k in
            tab i <> prettyTableName name
    

    Found in Universum.Container.Class from the package universum
        {-# INLINE toPairs #-}
        keys    = IM.keys
        {-# INLINE keys #-}
        elems   = IM.elems
        {-# INLINE elems #-}
    
    instance ToPairs (Map k v) where
        type Key (Map k v) = k
        type Val (Map k v) = v
        toPairs = M.toList
        {-# INLINE toPairs #-}
        keys    = M.keys
        {-# INLINE keys #-}
        elems   = M.elems
        {-# INLINE elems #-}
    
    ----------------------------------------------------------------------------
    -- Containers (e.g. tuples and Maybe aren't containers)
    ----------------------------------------------------------------------------
    

    Found in Universum.Container.Class from the package universum
        toPairs = IM.toList
        {-# INLINE toPairs #-}
        keys    = IM.keys
        {-# INLINE keys #-}
        elems   = IM.elems
        {-# INLINE elems #-}
    
    instance ToPairs (Map k v) where
        type Key (Map k v) = k
        type Val (Map k v) = v
        toPairs = M.toList
        {-# INLINE toPairs #-}
        keys    = M.keys
        {-# INLINE keys #-}
        elems   = M.elems
        {-# INLINE elems #-}
    
    ----------------------------------------------------------------------------
    -- Containers (e.g. tuples and Maybe aren't containers)
    ----------------------------------------------------------------------------
    

    Found in Universum.Container.Class from the package universum
        toPairs = IM.toList
        {-# INLINE toPairs #-}
        keys    = IM.keys
        {-# INLINE keys #-}
        elems   = IM.elems
        {-# INLINE elems #-}
    
    instance ToPairs (Map k v) where
        type Key (Map k v) = k
        type Val (Map k v) = v
        toPairs = M.toList
        {-# INLINE toPairs #-}
        keys    = M.keys
        {-# INLINE keys #-}
        elems   = M.elems
        {-# INLINE elems #-}
    
    ----------------------------------------------------------------------------
    -- Containers (e.g. tuples and Maybe aren't containers)
    ----------------------------------------------------------------------------
    

    Found in Universum.Container.Class from the package universum
        {-# INLINE toPairs #-}
        keys    = HM.keys
        {-# INLINE keys #-}
        elems   = HM.elems
        {-# INLINE elems #-}
    
    instance ToPairs (IntMap v) where
        type Key (IntMap v) = Int
        type Val (IntMap v) = v
        toPairs = IM.toList
        {-# INLINE toPairs #-}
        keys    = IM.keys
        {-# INLINE keys #-}
        elems   = IM.elems
        {-# INLINE elems #-}
    
    instance ToPairs (Map k v) where
        type Key (Map k v) = k
        type Val (Map k v) = v
        toPairs = M.toList
    

    Found in Universum.Container.Class from the package universum
        toPairs = HM.toList
        {-# INLINE toPairs #-}
        keys    = HM.keys
        {-# INLINE keys #-}
        elems   = HM.elems
        {-# INLINE elems #-}
    
    instance ToPairs (IntMap v) where
        type Key (IntMap v) = Int
        type Val (IntMap v) = v
        toPairs = IM.toList
        {-# INLINE toPairs #-}
        keys    = IM.keys
        {-# INLINE keys #-}
        elems   = IM.elems
        {-# INLINE elems #-}
    
    instance ToPairs (Map k v) where
        type Key (Map k v) = k
        type Val (Map k v) = v
    

    Found in Universum.Container.Class from the package universum
        toPairs = HM.toList
        {-# INLINE toPairs #-}
        keys    = HM.keys
        {-# INLINE keys #-}
        elems   = HM.elems
        {-# INLINE elems #-}
    
    instance ToPairs (IntMap v) where
        type Key (IntMap v) = Int
        type Val (IntMap v) = v
        toPairs = IM.toList
        {-# INLINE toPairs #-}
        keys    = IM.keys
        {-# INLINE keys #-}
        elems   = IM.elems
        {-# INLINE elems #-}
    
    instance ToPairs (Map k v) where
        type Key (Map k v) = k
        type Val (Map k v) = v
    

    Found in Universum.Container.Class from the package universum
        elems :: t -> [Val t]
        elems = map snd . toPairs
        {-# INLINE elems #-}
    
    -- Instances
    
    instance ToPairs (HashMap k v) where
        type Key (HashMap k v) = k
        type Val (HashMap k v) = v
        toPairs = HM.toList
        {-# INLINE toPairs #-}
        keys    = HM.keys
        {-# INLINE keys #-}
        elems   = HM.elems
        {-# INLINE elems #-}
    
    instance ToPairs (IntMap v) where
        type Key (IntMap v) = Int
        type Val (IntMap v) = v
        toPairs = IM.toList
    

    Found in Universum.Container.Class from the package universum
        -- ["xxx","yyy"]
        elems :: t -> [Val t]
        elems = map snd . toPairs
        {-# INLINE elems #-}
    
    -- Instances
    
    instance ToPairs (HashMap k v) where
        type Key (HashMap k v) = k
        type Val (HashMap k v) = v
        toPairs = HM.toList
        {-# INLINE toPairs #-}
        keys    = HM.keys
        {-# INLINE keys #-}
        elems   = HM.elems
        {-# INLINE elems #-}
    
    instance ToPairs (IntMap v) where
        type Key (IntMap v) = Int
        type Val (IntMap v) = v
    

    Found in Universum.Container.Class from the package universum
        -- ["xxx","yyy"]
        elems :: t -> [Val t]
        elems = map snd . toPairs
        {-# INLINE elems #-}
    
    -- Instances
    
    instance ToPairs (HashMap k v) where
        type Key (HashMap k v) = k
        type Val (HashMap k v) = v
        toPairs = HM.toList
        {-# INLINE toPairs #-}
        keys    = HM.keys
        {-# INLINE keys #-}
        elems   = HM.elems
        {-# INLINE elems #-}
    
    instance ToPairs (IntMap v) where
        type Key (IntMap v) = Int
        type Val (IntMap v) = v
    

    Found in Universum.Container.Class from the package universum
        -- | Converts the structure to the list of the keys.
        --
        -- >>> keys (HashMap.fromList [('a', "xxx"), ('b', "yyy")])
        -- "ab"
        keys :: t -> [Key t]
        keys = map fst . toPairs
        {-# INLINE keys #-}
    
        -- | Converts the structure to the list of the values.
        --
        -- >>> elems (HashMap.fromList [('a', "xxx"), ('b', "yyy")])
        -- ["xxx","yyy"]
        elems :: t -> [Val t]
        elems = map snd . toPairs
        {-# INLINE elems #-}
    
    -- Instances
    
    instance ToPairs (HashMap k v) where
        type Key (HashMap k v) = k
    

    Found in Universum.Container.Class from the package universum
        -- | Converts the structure to the list of the keys.
        --
        -- >>> keys (HashMap.fromList [('a', "xxx"), ('b', "yyy")])
        -- "ab"
        keys :: t -> [Key t]
        keys = map fst . toPairs
        {-# INLINE keys #-}
    
        -- | Converts the structure to the list of the values.
        --
        -- >>> elems (HashMap.fromList [('a', "xxx"), ('b', "yyy")])
        -- ["xxx","yyy"]
        elems :: t -> [Val t]
        elems = map snd . toPairs
        {-# INLINE elems #-}
    
    -- Instances
    
    instance ToPairs (HashMap k v) where
    

    Found in Universum.Container.Class from the package universum
        toPairs :: t -> [(Key t, Val t)]
    
        -- | Converts the structure to the list of the keys.
        --
        -- >>> keys (HashMap.fromList [('a', "xxx"), ('b', "yyy")])
        -- "ab"
        keys :: t -> [Key t]
        keys = map fst . toPairs
        {-# INLINE keys #-}
    
        -- | Converts the structure to the list of the values.
        --
        -- >>> elems (HashMap.fromList [('a', "xxx"), ('b', "yyy")])
        -- ["xxx","yyy"]
        elems :: t -> [Val t]
        elems = map snd . toPairs
        {-# INLINE elems #-}
    
    -- Instances
    

    empty See 75 Occurences [+] Collapse [-]
    Found in Data.Cache from the package cache
    --
    -- Items that are added to the cache without an explicit expiration value
    -- (using 'insert') will be inserted with the default expiration value.
    --
    -- If the specified default expiration value is `Nothing`, items inserted
    -- by 'insert' will never expire.
    newCache :: Maybe TimeSpec -> IO (Cache k v)
    newCache d = do
        m <- newTVarIO HM.empty
        return Cache { container = m, defaultExpiration = d }
    
    -- | STM variant of 'newCache'
    newCacheSTM :: Maybe TimeSpec -> STM (Cache k v)
    newCacheSTM d = do
        m <- newTVar HM.empty
        return Cache { container = m, defaultExpiration = d }
    
    copyCacheSTM :: Cache k v -> STM (Cache k v)
    copyCacheSTM c = do
        m <- newTVar =<< readTVar (container c)
    

    Found in Data.Cache from the package cache
        where f now' e
                | e < now'   = Just True
                | otherwise = Just False
    
    -- | Create a new cache with a default expiration value for newly
    -- added cache items.
    --
    -- Items that are added to the cache without an explicit expiration value
    -- (using 'insert') will be inserted with the default expiration value.
    --
    -- If the specified default expiration value is `Nothing`, items inserted
    -- by 'insert' will never expire.
    newCache :: Maybe TimeSpec -> IO (Cache k v)
    newCache d = do
        m <- newTVarIO HM.empty
        return Cache { container = m, defaultExpiration = d }
    
    -- | STM variant of 'newCache'
    newCacheSTM :: Maybe TimeSpec -> STM (Cache k v)
    newCacheSTM d = do
    

    Found in Country.Unexposed.Names from the package country
          HM.insert (T.pack [c1,c2]) (Country countryNum)
        $ HM.insert (T.pack [toLower c1, toLower c2]) (Country countryNum)
        $ hm
      )
      HM.empty countryNameQuads
    {-# NOINLINE alphaTwoHashMap #-}
    
    alphaThreeHashMap :: HashMap Text Country
    alphaThreeHashMap = L.foldl'
      (\hm (countryNum,_,_,(c1,c2,c3)) -> 
          HM.insert (T.pack [c1,c2,c3]) (Country countryNum)
        $ HM.insert (T.pack [toLower c1, toLower c2, toLower c3]) (Country countryNum)
        $ hm
      )
      HM.empty countryNameQuads
    {-# NOINLINE alphaThreeHashMap #-}
    

    Found in Country.Unexposed.Names from the package country
            else return ()
      clear 0
      forM_ countryNameQuads $ \(n,_,_,_) -> do
        writeByteArray m (word16ToInt n) (1 :: Word8)
      unsafeFreezeByteArray m
    {-# NOINLINE numericValidities #-}
    
    alphaTwoHashMap :: HashMap Text Country
    alphaTwoHashMap = L.foldl'
      (\hm (countryNum,_,(c1,c2),_) ->
          HM.insert (T.pack [c1,c2]) (Country countryNum)
        $ HM.insert (T.pack [toLower c1, toLower c2]) (Country countryNum)
        $ hm
      )
      HM.empty countryNameQuads
    {-# NOINLINE alphaTwoHashMap #-}
    
    alphaThreeHashMap :: HashMap Text Country
    alphaThreeHashMap = L.foldl'
      (\hm (countryNum,_,_,(c1,c2,c3)) -> 
    

    Found in Country.Unexposed.Names from the package country
       in hm3
    {-# NOINLINE decodeMap #-}
    
    -- This is only needed to support the reflex-platform fork of text. Fortunately,
    -- in all the places this is needed, it is only called to build CAFs.
    slowToTitle :: Text -> Text
    slowToTitle = T.intercalate (T.singleton ' ') . map upperFirst . T.splitOn (T.singleton ' ')
    
    upperFirst :: Text -> Text
    upperFirst t = case T.uncons t of
      Nothing -> T.empty
      Just (c,cs) -> T.cons (toUpper c) cs
    
    decodeMapUtf8 :: HashMap ByteString Country
    decodeMapUtf8 = HM.foldlWithKey' (\hm k v -> HM.insert (encodeUtf8 k) v hm) HM.empty decodeMap
    {-# NOINLINE decodeMapUtf8 #-}
    
    -- | A country recognized by ISO 3166.
    newtype Country = Country Word16
      deriving (Eq,Ord,Prim,Hashable,Storable,NFData,Generic)
    

    Found in Country.Unexposed.Names from the package country
      let baseMap = HM.union alphaTwoHashMap alphaThreeHashMap
          hm1 = L.foldl' (\hm (countryNum,name) -> HM.insert name (Country countryNum) hm) baseMap aliases
          hm2 = L.foldl' (\hm (countryNum,name,_,_) -> HM.insert name (Country countryNum) hm) hm1 countryNameQuads
          hm3 = HM.foldlWithKey' (\hm name cty -> HM.insert (T.toLower name) cty $ HM.insert (slowToTitle name) cty $ hm) hm2 hm2
       in hm3
    {-# NOINLINE decodeMap #-}
    
    -- This is only needed to support the reflex-platform fork of text. Fortunately,
    -- in all the places this is needed, it is only called to build CAFs.
    slowToTitle :: Text -> Text
    slowToTitle = T.intercalate (T.singleton ' ') . map upperFirst . T.splitOn (T.singleton ' ')
    
    upperFirst :: Text -> Text
    upperFirst t = case T.uncons t of
      Nothing -> T.empty
      Just (c,cs) -> T.cons (toUpper c) cs
    
    decodeMapUtf8 :: HashMap ByteString Country
    decodeMapUtf8 = HM.foldlWithKey' (\hm k v -> HM.insert (encodeUtf8 k) v hm) HM.empty decodeMap
    {-# NOINLINE decodeMapUtf8 #-}
    

    Found in Country.Unexposed.Names from the package country
      m <- newArray numberOfPossibleCodes unnamed
      mapM_ (\(ix,name,_,_) -> writeArray m (word16ToInt ix) name) countryNameQuads
      unsafeFreezeArray m
    {-# NOINLINE englishCountryNamesText #-}
    
    englishIdentifierNamesText :: Array Text
    englishIdentifierNamesText = runST $ do
      m <- newArray numberOfPossibleCodes unnamed
      mapM_ (\(ix,name,_,_) -> writeArray m (word16ToInt ix) (toIdentifier name)) countryNameQuads
      unsafeFreezeArray m
    {-# NOINLINE englishIdentifierNamesText #-}
    
    toIdentifier :: Text -> Text
    toIdentifier t = case (T.uncons . T.filter isAlpha . slowToTitle) t of
      Nothing -> T.empty
      Just (b,bs) -> T.cons (toLower b) bs
    
    
    unnamed :: Text
    unnamed = T.pack "Invalid Country"
    

    Found in Country.Unexposed.Trie from the package country
    placeholder :: Word16
    placeholder = 0xFFFF
    
    singleton :: Text -> Word16 -> Trie
    singleton fullName code = go fullName where
      go :: Text -> Trie
      go name = case T.uncons name of
        Just (char,nameNext) -> Trie placeholder (HM.singleton char (go nameNext))
        Nothing -> Trie code HM.empty
    
    instance Semigroup Trie where
      (<>) = mappend
    
    instance Monoid Trie where
      mempty = empty
      mappend = (SG.<>)
    
    trieFromList :: [(Text,Word16)] -> Trie
    trieFromList = foldMap (uncurry singleton)
    

    Found in Country.Unexposed.Trie from the package country
    empty :: Trie
    empty = Trie placeholder HM.empty
    
    append :: Trie -> Trie -> Trie
    append (Trie v1 c1) (Trie v2 c2) = Trie (min v1 v2) (HM.unionWith append c1 c2)
    
    placeholder :: Word16
    placeholder = 0xFFFF
    
    singleton :: Text -> Word16 -> Trie
    singleton fullName code = go fullName where
      go :: Text -> Trie
      go name = case T.uncons name of
        Just (char,nameNext) -> Trie placeholder (HM.singleton char (go nameNext))
        Nothing -> Trie code HM.empty
    
    instance Semigroup Trie where
      (<>) = mappend
    
    instance Monoid Trie where
    

    Found in Country.Unexposed.Trie from the package country
    import qualified Data.Text as T
    import qualified Data.HashMap.Strict as HM
    import qualified Data.Attoparsec.Text as AT
    import qualified Data.Semigroup as SG
    
    -- | If the value is not the max Word16 (65535), there 
    --   is a match. This means that 65535 cannot be used, which 
    --   is fine for this since 65535 is not used as a country code.
    data Trie = Trie
      { trieValue :: {-# UNPACK #-} !Word16
      , trieChildren :: !(HashMap Char Trie)
      }
    
    empty :: Trie
    empty = Trie placeholder HM.empty
    
    append :: Trie -> Trie -> Trie
    append (Trie v1 c1) (Trie v2 c2) = Trie (min v1 v2) (HM.unionWith append c1 c2)
    
    placeholder :: Word16
    

    Found in Country.Unexposed.Trie from the package country
    import qualified Data.Text as T
    import qualified Data.HashMap.Strict as HM
    import qualified Data.Attoparsec.Text as AT
    import qualified Data.Semigroup as SG
    
    -- | If the value is not the max Word16 (65535), there 
    --   is a match. This means that 65535 cannot be used, which 
    --   is fine for this since 65535 is not used as a country code.
    data Trie = Trie
      { trieValue :: {-# UNPACK #-} !Word16
      , trieChildren :: !(HashMap Char Trie)
      }
    
    empty :: Trie
    empty = Trie placeholder HM.empty
    
    append :: Trie -> Trie -> Trie
    append (Trie v1 c1) (Trie v2 c2) = Trie (min v1 v2) (HM.unionWith append c1 c2)
    
    placeholder :: Word16
    

    Found in Country.Unexposed.Trie from the package country
    import Control.Applicative ((<|>))
    import qualified Data.Text as T
    import qualified Data.HashMap.Strict as HM
    import qualified Data.Attoparsec.Text as AT
    import qualified Data.Semigroup as SG
    
    -- | If the value is not the max Word16 (65535), there 
    --   is a match. This means that 65535 cannot be used, which 
    --   is fine for this since 65535 is not used as a country code.
    data Trie = Trie
      { trieValue :: {-# UNPACK #-} !Word16
      , trieChildren :: !(HashMap Char Trie)
      }
    
    empty :: Trie
    empty = Trie placeholder HM.empty
    
    append :: Trie -> Trie -> Trie
    append (Trie v1 c1) (Trie v2 c2) = Trie (min v1 v2) (HM.unionWith append c1 c2)
    

    Found in Country.Unexposed.TrieByte from the package country
    placeholder :: Word16
    placeholder = 0xFFFF
    
    singleton :: ByteString -> Word16 -> TrieByte
    singleton fullName code = go fullName where
      go :: ByteString -> TrieByte
      go name = case B.uncons name of
        Just (char,nameNext) -> TrieByte placeholder (HM.singleton char (go nameNext))
        Nothing -> TrieByte code HM.empty
    
    instance Semigroup TrieByte where
      (<>) = append
    
    instance Monoid TrieByte where
      mempty = empty
      mappend = (SG.<>)
    
    trieByteFromList :: [(ByteString,Word16)] -> TrieByte
    trieByteFromList = foldMap (uncurry singleton)
    

    Found in Country.Unexposed.TrieByte from the package country
    empty :: TrieByte
    empty = TrieByte placeholder HM.empty
    
    append :: TrieByte -> TrieByte -> TrieByte
    append (TrieByte v1 c1) (TrieByte v2 c2) = TrieByte (min v1 v2) (HM.unionWith append c1 c2)
    
    placeholder :: Word16
    placeholder = 0xFFFF
    
    singleton :: ByteString -> Word16 -> TrieByte
    singleton fullName code = go fullName where
      go :: ByteString -> TrieByte
      go name = case B.uncons name of
        Just (char,nameNext) -> TrieByte placeholder (HM.singleton char (go nameNext))
        Nothing -> TrieByte code HM.empty
    
    instance Semigroup TrieByte where
      (<>) = append
    
    instance Monoid TrieByte where
    

    Found in Country.Unexposed.TrieByte from the package country
    import qualified Data.ByteString as B
    import qualified Data.HashMap.Strict as HM
    import qualified Data.Attoparsec.ByteString as AB
    import qualified Data.Semigroup as SG
    
    -- | If the value is not the max Word16 (65535), there 
    --   is a match. This means that 65535 cannot be used, which 
    --   is fine for this since 65535 is not used as a country code.
    data TrieByte = TrieByte
      { trieValue :: {-# UNPACK #-} !Word16
      , trieChildren :: !(HashMap Word8 TrieByte)
      }
    
    empty :: TrieByte
    empty = TrieByte placeholder HM.empty
    
    append :: TrieByte -> TrieByte -> TrieByte
    append (TrieByte v1 c1) (TrieByte v2 c2) = TrieByte (min v1 v2) (HM.unionWith append c1 c2)
    
    placeholder :: Word16
    

    Found in Country.Unexposed.TrieByte from the package country
    import qualified Data.ByteString as B
    import qualified Data.HashMap.Strict as HM
    import qualified Data.Attoparsec.ByteString as AB
    import qualified Data.Semigroup as SG
    
    -- | If the value is not the max Word16 (65535), there 
    --   is a match. This means that 65535 cannot be used, which 
    --   is fine for this since 65535 is not used as a country code.
    data TrieByte = TrieByte
      { trieValue :: {-# UNPACK #-} !Word16
      , trieChildren :: !(HashMap Word8 TrieByte)
      }
    
    empty :: TrieByte
    empty = TrieByte placeholder HM.empty
    
    append :: TrieByte -> TrieByte -> TrieByte
    append (TrieByte v1 c1) (TrieByte v2 c2) = TrieByte (min v1 v2) (HM.unionWith append c1 c2)
    
    placeholder :: Word16
    

    Found in Country.Unexposed.TrieByte from the package country
    import Control.Applicative ((<|>))
    import qualified Data.ByteString as B
    import qualified Data.HashMap.Strict as HM
    import qualified Data.Attoparsec.ByteString as AB
    import qualified Data.Semigroup as SG
    
    -- | If the value is not the max Word16 (65535), there 
    --   is a match. This means that 65535 cannot be used, which 
    --   is fine for this since 65535 is not used as a country code.
    data TrieByte = TrieByte
      { trieValue :: {-# UNPACK #-} !Word16
      , trieChildren :: !(HashMap Word8 TrieByte)
      }
    
    empty :: TrieByte
    empty = TrieByte placeholder HM.empty
    
    append :: TrieByte -> TrieByte -> TrieByte
    append (TrieByte v1 c1) (TrieByte v2 c2) = TrieByte (min v1 v2) (HM.unionWith append c1 c2)
    

    Found in Diagrams.Core.Style from the package diagrams-core
      {-# INLINE ix #-}
    
    instance At (Style v n) where
      at k = _Wrapped' . at k
      {-# INLINE at #-}
    
    -- | Combine a style by combining the attributes; if the two styles have
    --   attributes of the same type they are combined according to their
    --   semigroup structure.
    instance Typeable n => Semigroup (Style v n) where
      Style s1 <> Style s2 = Style $ HM.unionWith (<>) s1 s2
    
    -- | The empty style contains no attributes.
    instance Typeable n => Monoid (Style v n) where
      mempty  = Style HM.empty
      mappend = (<>)
    
    instance (Additive v, Traversable v, Floating n) => Transformable (Style v n) where
      transform t = over each (transform t)
    

    Found in Caching.ExpiringCacheMap.HashECM from the package expiring-cache-map
    invalidateCache ecm = do
      CacheState (_, maps0, _, (uses0, _), _) <- read m'maps
      case (HM.toList $ HM.intersection (HM.fromList $ reverse uses0) maps0) of
        [] -> return Nothing
        uses0' -> 
          let (id, _) = L.maximumBy (\(_,a) (_,b) -> compare a b) uses0' in
          case HM.lookup id maps0 of
            Just time_prev0 -> do
              prev0' <- enter m'maps $
                \(CacheState (retr_state, maps, _mapsize, _uses, _incr)) ->
                  let (_, _, prev) =
                        case HM.lookup id maps of
                          Just time_prev -> time_prev
                          Nothing -> time_prev0
                   in return (CacheState (retr_state, HM.empty, 0, ([], 0), 0), prev)
              return $ Just (id, prev0')
      where
        ECM ( m'maps, _, _, _, _, _, compactlistsize, enter, read ) = ecm
    

    Found in Caching.ExpiringCacheMap.HashECM from the package expiring-cache-map
    --  * When the modulo of the accumulator and a specified value equals to 0.
    --
    -- When the current time is determined during a lookup, access times of the
    -- entries in the key-value cache are compared with the new time to filter
    -- out expired entries from the key-value map.
    -- 
    lookupECM :: (Monad m, Eq k, Hashable k) => ECM m mv s HM.HashMap k v -> k -> m v
    lookupECM ecm id = do
      enter m'maps $
        \(CacheState (retr_state, maps, mapsize, uses, incr)) ->
          let incr' = incr + 1
           in if incr' < incr
                -- Word incrementor has cycled back to 0,
                -- so may as well clear the cache completely.
                then lookupECM' (retr_state, HM.empty, 0, ([], 0), 0) (0+1)
                else lookupECM' (retr_state, maps, mapsize, uses, incr) incr'
      where
      
        ECM ( m'maps, retr, gettime, minimumkeep, timecheckmodulo, removalsize, 
              compactlistsize, enter, _ro ) = ecm
    

    Found in Caching.ExpiringCacheMap.HashECM from the package expiring-cache-map
    -- 'CacheWithLRUList'.
    --
    newECMForM :: (Monad m1, Monad m2) => (Eq k, Hashable k) => (Maybe s -> k -> m1 (TimeUnits, (Maybe s, v))) -> (m1 TimeUnits)
      -> ECMIncr 
      -> CacheSettings
      -> ECMNewState m2 mv s HM.HashMap k v
      -> ECMEnterState m1 mv s HM.HashMap k v
      -> ECMReadState m1 mv s HM.HashMap k v
        -> m2 (ECM m1 mv s HM.HashMap k v)
    newECMForM retr gettime timecheckmodulo (CacheWithLRUList minimumkeep removalsize compactlistsize)
               newstate enterstate readstate =
      if timecheckmodulo <= 0
        then error "Modulo time check must be 1 or higher."
        else do
          m'maps <- newstate $ CacheState ( Nothing, HM.empty, 0, ([], 0), 0 )
          return $ ECM ( m'maps, retr, gettime, minimumkeep, 
                         timecheckmodulo, removalsize, compactlistsize,
                         enterstate, readstate )
    

    Found in Data.FuzzySet.Util from the package fuzzyset
    -- | Return the normalized Levenshtein distance between the two strings.
    distance  Text  Text  Double
    distance s t = fromRational (toRational d)
      where
        d = levenshteinNorm s t
    
    -- | @(\<$$\>) = fmap ∘ fmap@
    (<$$>)  (Functor f, Functor g)  (a  b)  g (f a)  g (f b)
    (<$$>) = fmap  fmap
    {-# INLINE (<$$>) #-}
    
    -- | Empty HashMap
    ε  HashMap k v
    ε = empty
    {-# INLINE ε #-}
    
    -- | Unicode minus sign symbol. Slightly longer than the hyphen-minus commonly
    --   used, U+2212 aligns naturally with the horizontal bar of the + symbol.
    ()  Num α  α  α  α
    

    Found in Data.FuzzySet.Util from the package fuzzyset
    {-# LANGUAGE UnicodeSyntax #-}
    module Data.FuzzySet.Util
      ( distance
      , enclosedIn
      , normalized
      , norm
      , substr
      , ε
      , (<$$>)
      , ()
      , (×)
      ) where
    
    import Data.Char                       ( isAlphaNum, isSpace )
    import Data.HashMap.Strict             ( HashMap, empty )
    import Data.Text                       ( Text, cons, snoc )
    import Data.Text.Metrics
    import Prelude.Unicode
    
    import qualified Data.Text             as Text
    

    Found in Text.Glabrous from the package glabrous
              case H.lookup k variables of
                Just v  -> Literal v
                Nothing -> i
            trans t = t
    
    -- | Process a (sub)'Context' present in the given template, and
    -- get either a 'Final' 'T.Text' or a new 'Template' with its unset
    -- ad hoc 'Context'.
    --
    -- >λ>partialProcess' template context
    -- >Partial {template = Template {content = [Literal "Some ",Tag "tags",Literal " are unused in this ",Tag "text",Literal "."]}, context = Context {variables = fromList [("text",""),("tags","")]}}
    partialProcess' :: Template -> Context -> G.Result
    partialProcess' t c@Context{..} =
      case foldl trans ([],[]) (content t) of
        (f,[]) -> Final $ toTextWithContext (const T.empty) c f
        (p,p') -> G.Partial Template { content = p } (fromTagsList p')
      where
        trans (!c',!ts) t' =
          case t' of
            Tag k ->
    

    Found in Text.Glabrous from the package glabrous
        rename t@(Tag n) =
          case lookup n ts of
            Just r  -> Tag r
            Nothing -> t
        rename l@(Literal _) = l
    
    -- | 'True' if a 'Template' has no more 'Tag'
    -- inside and can be used as a final 'T.Text'.
    isFinal :: Template -> Bool
    isFinal Template{..} = all isLiteral content
    
    -- | Process, discard 'Tag's which are not in the 'Context'
    -- and replace them with nothing in the final 'T.Text'.
    process :: Template -> Context -> T.Text
    process = processWithDefault T.empty
    
    -- | Process and replace missing variables in 'Context'
    -- with the given default replacement 'T.Text'.
    processWithDefault
      :: T.Text    -- ^ Default replacement text
    

    Found in Text.Glabrous from the package glabrous
    -- | Output the content of the given 'Template'
    -- as it is, with its 'Tag's, if they exist.
    toText :: Template -> T.Text
    toText Template{..} =
      T.concat $ trans <$> content
      where
        trans (Literal c) = c
        trans (Tag k)     = T.concat ["{{",k,"}}"]
    
    -- | Output the content of the given 'Template'
    -- with all its 'Tag's removed.
    toFinalText :: Template -> T.Text
    toFinalText Template{..} =
      foldl trans T.empty content
      where
        trans o (Literal l) = o `T.append` l
        trans o (Tag _) = o
    
    -- | Get the list of 'Tag's in the given 'Template'.
    

    Found in Text.Glabrous from the package glabrous
    --
    -- >λ>unsetContext context
    -- >Just (Context {variables = fromList [("name","")]})
    --
    unsetContext :: Context -> Maybe Context
    unsetContext Context {..} = do
      let vs = H.filter (== T.empty) variables
      guard (vs /= H.empty)
      return Context { variables = vs }
    
    -- | 'True' if the all variables of
    -- the given 'Context' are not empty.
    isSet :: Context -> Bool
    isSet Context{..} =
      H.foldr (\v b -> b && v /= T.empty) True variables
    
    -- | Get the list of the given 'Context' variables.
    variablesOf :: Context -> [T.Text]
    variablesOf Context{..} = H.keys variables
    

    Found in Text.Glabrous from the package glabrous
    --
    initContextFile :: FilePath -> Context -> IO ()
    initContextFile f Context {..} = L.writeFile f $
      encodePretty Context { variables = H.map (const T.empty) variables }
    
    -- | Build 'Just' a (sub)'Context' made of unset variables
    -- of the given context, or 'Nothing'.
    --
    -- >λ>unsetContext context
    -- >Just (Context {variables = fromList [("name","")]})
    --
    unsetContext :: Context -> Maybe Context
    unsetContext Context {..} = do
      let vs = H.filter (== T.empty) variables
      guard (vs /= H.empty)
      return Context { variables = vs }
    
    -- | 'True' if the all variables of
    -- the given 'Context' are not empty.
    isSet :: Context -> Bool
    

    Found in Text.Glabrous from the package glabrous
    -- @
    --
    initContextFile :: FilePath -> Context -> IO ()
    initContextFile f Context {..} = L.writeFile f $
      encodePretty Context { variables = H.map (const T.empty) variables }
    
    -- | Build 'Just' a (sub)'Context' made of unset variables
    -- of the given context, or 'Nothing'.
    --
    -- >λ>unsetContext context
    -- >Just (Context {variables = fromList [("name","")]})
    --
    unsetContext :: Context -> Maybe Context
    unsetContext Context {..} = do
      let vs = H.filter (== T.empty) variables
      guard (vs /= H.empty)
      return Context { variables = vs }
    
    -- | 'True' if the all variables of
    -- the given 'Context' are not empty.
    

    Found in Text.Glabrous from the package glabrous
    writeContextFile f c = L.writeFile f $ encodePretty c
    
    -- | Based on the given 'Context', write a JSON
    -- 'Context' file with all its variables empty.
    --
    -- @
    -- {
    --     "tag": "",
    --     "etc.": ""
    -- }
    -- @
    --
    initContextFile :: FilePath -> Context -> IO ()
    initContextFile f Context {..} = L.writeFile f $
      encodePretty Context { variables = H.map (const T.empty) variables }
    
    -- | Build 'Just' a (sub)'Context' made of unset variables
    -- of the given context, or 'Nothing'.
    --
    -- >λ>unsetContext context
    

    Found in Text.Glabrous from the package glabrous
    -- >Context {variables = fromList [("etc.","..."),("tag","replacement")]}
    --
    fromList :: [(T.Text, T.Text)] -> Context
    fromList ts = Context { variables = H.fromList ts }
    
    -- | Build an unset 'Context' from a list of 'Tag's.
    --
    -- >λ>fromTagsList ["tag","etc."]
    -- >Context {variables = fromList [("etc.",""),("tag","")]}
    fromTagsList :: [T.Text] -> Context
    fromTagsList ts = fromList $ (\t -> (t,T.empty)) <$> ts
    
    -- | Build an unset ad hoc 'Context' from the given 'Template'.
    fromTemplate :: Template -> Context
    fromTemplate t = setVariables ((\e -> (e,T.empty)) <$> tagsOf t) initContext
    
    -- | Get a 'Context' from a JSON file.
    readContextFile :: FilePath -> IO (Maybe Context)
    readContextFile f = decode <$> L.readFile f
    

    Found in Text.Glabrous from the package glabrous
    -- | Build a 'Context' from a list of 'Tag's and replacement 'T.Text's.
    --
    -- >λ>fromList [("tag","replacement"), ("etc.","...")]
    -- >Context {variables = fromList [("etc.","..."),("tag","replacement")]}
    --
    fromList :: [(T.Text, T.Text)] -> Context
    fromList ts = Context { variables = H.fromList ts }
    
    -- | Build an unset 'Context' from a list of 'Tag's.
    --
    -- >λ>fromTagsList ["tag","etc."]
    -- >Context {variables = fromList [("etc.",""),("tag","")]}
    fromTagsList :: [T.Text] -> Context
    fromTagsList ts = fromList $ (\t -> (t,T.empty)) <$> ts
    
    -- | Build an unset ad hoc 'Context' from the given 'Template'.
    fromTemplate :: Template -> Context
    fromTemplate t = setVariables ((\e -> (e,T.empty)) <$> tagsOf t) initContext
    

    Found in Text.Glabrous from the package glabrous
              Just (c,d) -> go d (ac ++ [concatLiterals a] ++ [c])
              Nothing    -> ac ++ [concatLiterals a]
            else case u of
              Just (e,f) -> go f (ac ++ [e])
              Nothing    -> ac
          where
            concatLiterals =
              foldr trans (Literal "")
              where
                trans (Literal a) (Literal b) = Literal (a `T.append` b)
                trans _           _           = undefined
    
    -- | Build an empty 'Context'.
    initContext :: Context
    initContext = Context { variables = H.empty }
    
    -- | Populate with variables and/or update variables in the given 'Context'.
    --
    -- >λ>setVariables [("tag","replacement"), ("theme","Haskell")] context
    -- >Context {variables = fromList [("etc.","..."),("theme","Haskell"),("tag","replacement"),("name","")]}
    

    Found in Data.Core.Graph.NodeManager from the package graph-core
    hasKey :: (Eq k, Hashable k) => k -> NodeManager k -> Bool
    hasKey k nm =
        isJust $ HM.lookup k (nm_keyToNode nm)
    
    toList :: NodeManager k -> [(k, Node)]
    toList nm = HM.toList (nm_keyToNode nm)
    
    nodes :: NodeManager k -> [Node]
    nodes nm = IM.keys (nm_nodeToKey nm)
    
    getNewNodesSince :: Node -> NodeManager k -> NodeMap k
    getNewNodesSince n (NodeManager{..}) = snd $ IM.split n nm_nodeToKey
    
    emptyNodeManager :: forall k. NodeManager k
    emptyNodeManager = NodeManager IM.empty HM.empty 0
    
    getNodeHandle :: (Hashable k, Eq k, MonadState (NodeManager k) m) => k -> m Node
    getNodeHandle k =
        do NodeManager{..} <- get
           case HM.lookup k nm_keyToNode of
    

    Found in Data.Core.Graph.NodeManager from the package graph-core
    hasKey :: (Eq k, Hashable k) => k -> NodeManager k -> Bool
    hasKey k nm =
        isJust $ HM.lookup k (nm_keyToNode nm)
    
    toList :: NodeManager k -> [(k, Node)]
    toList nm = HM.toList (nm_keyToNode nm)
    
    nodes :: NodeManager k -> [Node]
    nodes nm = IM.keys (nm_nodeToKey nm)
    
    getNewNodesSince :: Node -> NodeManager k -> NodeMap k
    getNewNodesSince n (NodeManager{..}) = snd $ IM.split n nm_nodeToKey
    
    emptyNodeManager :: forall k. NodeManager k
    emptyNodeManager = NodeManager IM.empty HM.empty 0
    
    getNodeHandle :: (Hashable k, Eq k, MonadState (NodeManager k) m) => k -> m Node
    getNodeHandle k =
        do NodeManager{..} <- get
           case HM.lookup k nm_keyToNode of
    

    Found in Haxl.Core.DataCache from the package haxl
    -- | The implementation is a two-level map: the outer level maps the
    -- types of requests to 'SubCache', which maps actual requests to their
    -- results.  So each 'SubCache' contains requests of the same type.
    -- This works well because we only have to store the dictionaries for
    -- 'Hashable' and 'Eq' once per request type.
    --
    data SubCache res =
      forall req a . (Hashable (req a), Eq (req a), Typeable (req a)) =>
           SubCache (req a -> String) (a -> String) ! (HashMap (req a) (res a))
           -- NB. the inner HashMap is strict, to avoid building up
           -- a chain of thunks during repeated insertions.
    
    -- | A new, empty 'DataCache'.
    emptyDataCache :: DataCache res
    emptyDataCache = DataCache HashMap.empty
    
    
    -- | Inserts a request-result pair into the 'DataCache'.
    insert
      :: (Hashable (req a), Typeable (req a), Eq (req a), Show (req a), Show a)
    

    Found in Network.Http.Internal from the package http-common
    --
    -- | Given a list of field-name,field-value pairs, construct a Headers map.
    --
    {-
        This is only going to be used by RequestBuilder and ResponseParser,
        obviously. And yes, as usual, we go to a lot of trouble to splice out the
        function doing the work, in the name of type sanity.
    -}
    buildHeaders :: [(ByteString, ByteString)] -> Headers
    buildHeaders hs =
        Wrap result
      where
        result = foldl' addHeader empty hs
    
    {-
        insertWith is used here for the case where a header is repeated
        (for example, Set-Cookie) and the values need to be intercalated
        with ',' as per RFC 2616 §4.2.
    

    Found in Network.Http.Internal from the package http-common
    joinHeaders :: HashMap (CI ByteString) ByteString -> Builder
    joinHeaders m = foldrWithKey combine mempty m
    
    combine :: CI ByteString -> ByteString -> Builder -> Builder
    combine k v acc =
        mconcat [acc, key, Builder.fromString ": ", value, crlf]
      where
        key = Builder.copyByteString $ original k
        value = Builder.fromByteString v
    {-# INLINE combine #-}
    
    emptyHeaders :: Headers
    emptyHeaders =
        Wrap empty
    
    --
    -- | Set a header field to the specified value. This will overwrite
    -- any existing value for the field. Remember that HTTP fields names
    -- are case insensitive!
    

    Found in Network.Http.Internal from the package http-common
    import Blaze.ByteString.Builder (Builder)
    import qualified Blaze.ByteString.Builder as Builder (copyByteString,
                                                          copyByteString,
                                                          fromByteString,
                                                          fromByteString,
                                                          toByteString)
    import qualified Blaze.ByteString.Builder.Char8 as Builder (fromChar,
                                                                fromShow,
                                                                fromString)
    import Control.Exception (Exception)
    import Data.ByteString (ByteString)
    import qualified Data.ByteString.Char8 as S
    import Data.CaseInsensitive (CI, mk, original)
    import Data.HashMap.Strict (HashMap, delete, empty, foldrWithKey, insert,
                                insertWith, lookup, toList)
    import Data.Int (Int64)
    import Data.List (foldl')
    import Data.Monoid (mconcat, mempty)
    import Data.Typeable (Typeable)
    

    Found in Data.Interned.Internal from the package intern
       , content :: !(HashMap (Description t) t)
       }
    
    newtype Cache t = Cache { getCache :: Array Int (IORef (CacheState t)) }
    
    cacheSize :: Cache t -> IO Int
    cacheSize (Cache t) = foldrM
       (\a b -> do
           v <- readIORef a
           return $! HashMap.size (content v) + b
       ) 0 t
    
    mkCache :: Interned t => Cache t
    mkCache   = result where
      element = CacheState (seedIdentity result) HashMap.empty
      w       = cacheWidth result
      result  = Cache
              $ unsafePerformIO
              $ traverse newIORef
              $ listArray (0,w - 1)
    

    Found in Crypto.JWT from the package jose
    -- /jti/ value is a case-sensitive string.
    claimJti :: Lens' ClaimsSet (Maybe T.Text)
    claimJti f h@(ClaimsSet { _claimJti = a}) =
      fmap (\a' -> h { _claimJti = a' }) (f a)
    
    -- | Claim Names can be defined at will by those using JWTs.
    unregisteredClaims :: Lens' ClaimsSet (M.HashMap T.Text Value)
    unregisteredClaims f h@(ClaimsSet { _unregisteredClaims = a}) =
      fmap (\a' -> h { _unregisteredClaims = a' }) (f a)
    
    
    -- | Return an empty claims set.
    --
    emptyClaimsSet :: ClaimsSet
    emptyClaimsSet = ClaimsSet n n n n n n n M.empty where n = Nothing
    
    addClaim :: T.Text -> Value -> ClaimsSet -> ClaimsSet
    addClaim k v = over unregisteredClaims (M.insert k v)
    
    filterUnregistered :: M.HashMap T.Text Value -> M.HashMap T.Text Value
    

    Found in Data.Aeson.AutoType.Type from the package json-autotype
    instance Biplate (HashMap k v) v where
      biplate m = (Hash.elems m, Hash.fromList . zip (Hash.keys m))
     -}
    
    instance Uniplate Type where
      uniplate (TUnion s) = (Set.toList s, TUnion .        Set.fromList                     )
      uniplate (TObj   d) = (Hash.elems m, TObj   . Dict . Hash.fromList . zip (Hash.keys m))
        where
          m = unDict d
      uniplate (TArray t) = ([t],          TArray . head  )
      uniplate s          = ([],           const s        )
    
    -- | Empty type
    emptyType :: Type
    emptyType = TUnion Set.empty
    
    -- | Lookup the Type within the dictionary.
    get :: Text -> Dict -> Type
    get key = Hash.lookupDefault TNull key . unDict
    

    Found in Data.Aeson.AutoType.CodeGen.HaskellFormat from the package json-autotype
    splitTypeByLabel' l (TArray a) = do m <- splitTypeByLabel' (l `Text.append` "Elt") a
                                        return $! TArray m
    splitTypeByLabel' l (TObj   o) = do kvs <- forM (Map.toList $ unDict o) $ \(k, v) -> do
                                           component <- splitTypeByLabel' k v
                                           return (k, component)
                                        addType l (TObj $ Dict $ Map.fromList kvs)
                                        return $! TLabel l
    
    -- | Splits initial type with a given label, into a mapping of object type names and object type structures.
    splitTypeByLabel :: Text -> Type -> Map Text Type
    splitTypeByLabel topLabel t = Map.map (foldl1' unifyTypes) finalState
      where
        finalize (TLabel l) = assert (l == topLabel) $ return ()
        finalize  topLevel  = addType topLabel topLevel
        initialState    = Map.empty
        (_, finalState) = runState (splitTypeByLabel' topLabel t >>= finalize) initialState
    
    formatObjectType ::  Text -> Type -> DeclM Text
    formatObjectType identifier (TObj o) = newDecl  identifier d
      where
    

    Found in Data.Aeson.AutoType.Split from the package json-autotype
    splitTypeByLabel' l (TArray a) = do m <- splitTypeByLabel' (l `Text.append` "Elt") a
                                        return $! TArray m
    splitTypeByLabel' l (TObj   o) = do kvs <- forM (Map.toList $ unDict o) $ \(k, v) -> do
                                           component <- splitTypeByLabel' k v
                                           return (k, component)
                                        addType l (TObj $ Dict $ Map.fromList kvs)
                                        return $! TLabel l
    
    -- | Splits initial type with a given label, into a mapping of object type names and object type structures.
    splitTypeByLabel :: Text -> Type -> Map Text Type
    splitTypeByLabel topLabel t = Map.map (foldl1' unifyTypes) finalState
      where
        finalize (TLabel l) = assert (l == topLabel) $ return ()
        finalize  topLevel  = addType topLabel topLevel
        initialState    = Map.empty
        (_, finalState) = runState (splitTypeByLabel' topLabel t >>= finalize) initialState
    
    -- | Topological sorting of splitted types so that it is accepted declaration order.
    toposort :: Map Text Type -> [(Text, Type)]  
    toposort splitted = map ((id &&& (splitted Map.!)) . fst3 . graphKey) $ Graph.topSort graph
    

    Found in Data.Aeson.AutoType.Type from the package json-autotype
    instance Biplate (HashMap k v) v where
      biplate m = (Hash.elems m, Hash.fromList . zip (Hash.keys m))
     -}
    
    instance Uniplate Type where
      uniplate (TUnion s) = (Set.toList s, TUnion .        Set.fromList                     )
      uniplate (TObj   d) = (Hash.elems m, TObj   . Dict . Hash.fromList . zip (Hash.keys m))
        where
          m = unDict d
      uniplate (TArray t) = ([t],          TArray . head  )
      uniplate s          = ([],           const s        )
    
    -- | Empty type
    emptyType :: Type
    emptyType = TUnion Set.empty
    
    -- | Lookup the Type within the dictionary.
    get :: Text -> Dict -> Type
    get key = Hash.lookupDefault TNull key . unDict
    

    Found in Data.Aeson.AutoType.Type from the package json-autotype
    instance Biplate (HashMap k v) v where
      biplate m = (Hash.elems m, Hash.fromList . zip (Hash.keys m))
     -}
    
    instance Uniplate Type where
      uniplate (TUnion s) = (Set.toList s, TUnion .        Set.fromList                     )
      uniplate (TObj   d) = (Hash.elems m, TObj   . Dict . Hash.fromList . zip (Hash.keys m))
        where
          m = unDict d
      uniplate (TArray t) = ([t],          TArray . head  )
      uniplate s          = ([],           const s        )
    
    -- | Empty type
    emptyType :: Type
    emptyType = TUnion Set.empty
    
    -- | Lookup the Type within the dictionary.
    get :: Text -> Dict -> Type
    get key = Hash.lookupDefault TNull key . unDict
    

    Found in Data.Aeson.AutoType.Split from the package json-autotype
    splitTypeByLabel' l (TArray a) = do m <- splitTypeByLabel' (l `Text.append` "Elt") a
                                        return $! TArray m
    splitTypeByLabel' l (TObj   o) = do kvs <- forM (Map.toList $ unDict o) $ \(k, v) -> do
                                           component <- splitTypeByLabel' k v
                                           return (k, component)
                                        addType l (TObj $ Dict $ Map.fromList kvs)
                                        return $! TLabel l
    
    -- | Splits initial type with a given label, into a mapping of object type names and object type structures.
    splitTypeByLabel :: Text -> Type -> Map Text Type
    splitTypeByLabel topLabel t = Map.map (foldl1' unifyTypes) finalState
      where
        finalize (TLabel l) = assert (l == topLabel) $ return ()
        finalize  topLevel  = addType topLabel topLevel
        initialState    = Map.empty
        (_, finalState) = runState (splitTypeByLabel' topLabel t >>= finalize) initialState
    
    -- | Topological sorting of splitted types so that it is accepted declaration order.
    toposort :: Map Text Type -> [(Text, Type)]  
    toposort splitted = map ((id &&& (splitted Map.!)) . fst3 . graphKey) $ Graph.topSort graph
    

    Found in Data.Aeson.AutoType.CodeGen.HaskellFormat from the package json-autotype
    splitTypeByLabel' l (TArray a) = do m <- splitTypeByLabel' (l `Text.append` "Elt") a
                                        return $! TArray m
    splitTypeByLabel' l (TObj   o) = do kvs <- forM (Map.toList $ unDict o) $ \(k, v) -> do
                                           component <- splitTypeByLabel' k v
                                           return (k, component)
                                        addType l (TObj $ Dict $ Map.fromList kvs)
                                        return $! TLabel l
    
    -- | Splits initial type with a given label, into a mapping of object type names and object type structures.
    splitTypeByLabel :: Text -> Type -> Map Text Type
    splitTypeByLabel topLabel t = Map.map (foldl1' unifyTypes) finalState
      where
        finalize (TLabel l) = assert (l == topLabel) $ return ()
        finalize  topLevel  = addType topLabel topLevel
        initialState    = Map.empty
        (_, finalState) = runState (splitTypeByLabel' topLabel t >>= finalize) initialState
    
    formatObjectType ::  Text -> Type -> DeclM Text
    formatObjectType identifier (TObj o) = newDecl  identifier d
      where
    

    Found in Data.Aeson.AutoType.Type from the package json-autotype
    instance Biplate (HashMap k v) v where
      biplate m = (Hash.elems m, Hash.fromList . zip (Hash.keys m))
     -}
    
    instance Uniplate Type where
      uniplate (TUnion s) = (Set.toList s, TUnion .        Set.fromList                     )
      uniplate (TObj   d) = (Hash.elems m, TObj   . Dict . Hash.fromList . zip (Hash.keys m))
        where
          m = unDict d
      uniplate (TArray t) = ([t],          TArray . head  )
      uniplate s          = ([],           const s        )
    
    -- | Empty type
    emptyType :: Type
    emptyType = TUnion Set.empty
    
    -- | Lookup the Type within the dictionary.
    get :: Text -> Dict -> Type
    get key = Hash.lookupDefault TNull key . unDict
    

    Found in Data.Aeson.AutoType.Split from the package json-autotype
    splitTypeByLabel' l (TArray a) = do m <- splitTypeByLabel' (l `Text.append` "Elt") a
                                        return $! TArray m
    splitTypeByLabel' l (TObj   o) = do kvs <- forM (Map.toList $ unDict o) $ \(k, v) -> do
                                           component <- splitTypeByLabel' k v
                                           return (k, component)
                                        addType l (TObj $ Dict $ Map.fromList kvs)
                                        return $! TLabel l
    
    -- | Splits initial type with a given label, into a mapping of object type names and object type structures.
    splitTypeByLabel :: Text -> Type -> Map Text Type
    splitTypeByLabel topLabel t = Map.map (foldl1' unifyTypes) finalState
      where
        finalize (TLabel l) = assert (l == topLabel) $ return ()
        finalize  topLevel  = addType topLabel topLevel
        initialState    = Map.empty
        (_, finalState) = runState (splitTypeByLabel' topLabel t >>= finalize) initialState
    
    -- | Topological sorting of splitted types so that it is accepted declaration order.
    toposort :: Map Text Type -> [(Text, Type)]  
    toposort splitted = map ((id &&& (splitted Map.!)) . fst3 . graphKey) $ Graph.topSort graph
    

    Found in Data.Aeson.AutoType.CodeGen.HaskellFormat from the package json-autotype
    splitTypeByLabel' l (TArray a) = do m <- splitTypeByLabel' (l `Text.append` "Elt") a
                                        return $! TArray m
    splitTypeByLabel' l (TObj   o) = do kvs <- forM (Map.toList $ unDict o) $ \(k, v) -> do
                                           component <- splitTypeByLabel' k v
                                           return (k, component)
                                        addType l (TObj $ Dict $ Map.fromList kvs)
                                        return $! TLabel l
    
    -- | Splits initial type with a given label, into a mapping of object type names and object type structures.
    splitTypeByLabel :: Text -> Type -> Map Text Type
    splitTypeByLabel topLabel t = Map.map (foldl1' unifyTypes) finalState
      where
        finalize (TLabel l) = assert (l == topLabel) $ return ()
        finalize  topLevel  = addType topLabel topLevel
        initialState    = Map.empty
        (_, finalState) = runState (splitTypeByLabel' topLabel t >>= finalize) initialState
    
    formatObjectType ::  Text -> Type -> DeclM Text
    formatObjectType identifier (TObj o) = newDecl  identifier d
      where
    

    Found in Data.Aeson.AutoType.Type from the package json-autotype
    instance Biplate (HashMap k v) v where
      biplate m = (Hash.elems m, Hash.fromList . zip (Hash.keys m))
     -}
    
    instance Uniplate Type where
      uniplate (TUnion s) = (Set.toList s, TUnion .        Set.fromList                     )
      uniplate (TObj   d) = (Hash.elems m, TObj   . Dict . Hash.fromList . zip (Hash.keys m))
        where
          m = unDict d
      uniplate (TArray t) = ([t],          TArray . head  )
      uniplate s          = ([],           const s        )
    
    -- | Empty type
    emptyType :: Type
    emptyType = TUnion Set.empty
    
    -- | Lookup the Type within the dictionary.
    get :: Text -> Dict -> Type
    get key = Hash.lookupDefault TNull key . unDict
    

    Found in Data.Aeson.AutoType.Split from the package json-autotype
    splitTypeByLabel' l (TArray a) = do m <- splitTypeByLabel' (l `Text.append` "Elt") a
                                        return $! TArray m
    splitTypeByLabel' l (TObj   o) = do kvs <- forM (Map.toList $ unDict o) $ \(k, v) -> do
                                           component <- splitTypeByLabel' k v
                                           return (k, component)
                                        addType l (TObj $ Dict $ Map.fromList kvs)
                                        return $! TLabel l
    
    -- | Splits initial type with a given label, into a mapping of object type names and object type structures.
    splitTypeByLabel :: Text -> Type -> Map Text Type
    splitTypeByLabel topLabel t = Map.map (foldl1' unifyTypes) finalState
      where
        finalize (TLabel l) = assert (l == topLabel) $ return ()
        finalize  topLevel  = addType topLabel topLevel
        initialState    = Map.empty
        (_, finalState) = runState (splitTypeByLabel' topLabel t >>= finalize) initialState
    
    -- | Topological sorting of splitted types so that it is accepted declaration order.
    toposort :: Map Text Type -> [(Text, Type)]  
    toposort splitted = map ((id &&& (splitted Map.!)) . fst3 . graphKey) $ Graph.topSort graph
    

    Found in Data.Aeson.AutoType.CodeGen.HaskellFormat from the package json-autotype
    splitTypeByLabel' l (TArray a) = do m <- splitTypeByLabel' (l `Text.append` "Elt") a
                                        return $! TArray m
    splitTypeByLabel' l (TObj   o) = do kvs <- forM (Map.toList $ unDict o) $ \(k, v) -> do
                                           component <- splitTypeByLabel' k v
                                           return (k, component)
                                        addType l (TObj $ Dict $ Map.fromList kvs)
                                        return $! TLabel l
    
    -- | Splits initial type with a given label, into a mapping of object type names and object type structures.
    splitTypeByLabel :: Text -> Type -> Map Text Type
    splitTypeByLabel topLabel t = Map.map (foldl1' unifyTypes) finalState
      where
        finalize (TLabel l) = assert (l == topLabel) $ return ()
        finalize  topLevel  = addType topLabel topLevel
        initialState    = Map.empty
        (_, finalState) = runState (splitTypeByLabel' topLabel t >>= finalize) initialState
    
    formatObjectType ::  Text -> Type -> DeclM Text
    formatObjectType identifier (TObj o) = newDecl  identifier d
      where
    

    Found in Web.JWT from the package jwt
      , nbf                :: Maybe IntDate
    
        -- | The iat (issued at) claim identifies the time at which the JWT was issued.
      , iat                :: Maybe IntDate
    
        -- | The jti (JWT ID) claim provides a unique identifier for the JWT.
      , jti                :: Maybe StringOrURI
    
      , unregisteredClaims :: ClaimsMap
    
    } deriving (Show, Eq)
    
    
    instance Default JWTClaimsSet where
        def = JWTClaimsSet Nothing Nothing Nothing Nothing Nothing Nothing Nothing Map.empty
    
    
    -- | Encode a claims set using the given secret
    --
    --  @
    

    Found in Web.JWT from the package jwt
      , nbf                :: Maybe IntDate
    
        -- | The iat (issued at) claim identifies the time at which the JWT was issued.
      , iat                :: Maybe IntDate
    
        -- | The jti (JWT ID) claim provides a unique identifier for the JWT.
      , jti                :: Maybe StringOrURI
    
      , unregisteredClaims :: ClaimsMap
    
    } deriving (Show, Eq)
    
    
    instance Default JWTClaimsSet where
        def = JWTClaimsSet Nothing Nothing Nothing Nothing Nothing Nothing Nothing Map.empty
    
    
    -- | Encode a claims set using the given secret
    --
    --  @
    

    Found in Data.Metrics.Registry from the package metrics
      module Data.Metrics.Types
    ) where
    import Control.Concurrent.MVar
    import qualified Data.HashMap.Strict as H
    import Data.Metrics.Counter
    import Data.Metrics.Gauge
    import Data.Metrics.Histogram
    import Data.Metrics.Meter
    import Data.Metrics.Timer
    import Data.Metrics.Types
    import Data.Text (Text)
    
    -- | Initializes a new metric registry.
    newMetricRegistry :: IO (MetricRegistry IO)
    newMetricRegistry = fmap MetricRegistry $ newMVar H.empty
    
    -- | A container that tracks all metrics registered with it.
    -- All forms of metrics share the same namespace in the registry.
    -- Consequently, attempting to replace a metric with one of a different type will fail (return Nothing from a call to `register`).
    data MetricRegistry m = MetricRegistry
    

    Found in Text.MMark.Parser.Internal.Type from the package mmark
      deriving (Eq, Ord, Show)
    
    ----------------------------------------------------------------------------
    -- Reference and footnote definitions
    
    -- | An opaque container for reference and footnote definitions.
    
    newtype Defs = Defs
      { _referenceDefs :: HashMap DefLabel (URI, Maybe Text)
        -- ^ Reference definitions containing a 'URI' and optionally title
      }
    
    instance Default Defs where
      def = Defs
        { _referenceDefs = HM.empty
        }
    
    -- | An opaque type for definition label.
    
    newtype DefLabel = DefLabel (CI Text)
    

    Found in Data.HashMap.Monoidal from the package monoidal-containers
          Nothing -> maybe (MonoidalHashMap m) (const (MonoidalHashMap $ M.delete k m)) mv
          Just v' -> MonoidalHashMap $ M.insert k v' m
          where mv = M.lookup k m
        {-# INLINE at #-}
    
    instance Each (MonoidalHashMap k a) (MonoidalHashMap k b) a b
    
    instance (Eq k, Hashable k) => FunctorWithIndex k (MonoidalHashMap k)
    instance (Eq k, Hashable k) => FoldableWithIndex k (MonoidalHashMap k)
    instance (Eq k, Hashable k) => TraversableWithIndex k (MonoidalHashMap k) where
        itraverse f (MonoidalHashMap m) = fmap MonoidalHashMap $ itraverse f m
        {-# INLINE itraverse #-}
    
    instance AsEmpty (MonoidalHashMap k a) where
        _Empty = nearly (MonoidalHashMap M.empty) (M.null . unpack)
        {-# INLINE _Empty #-}
    
    instance Wrapped (MonoidalHashMap k a) where
        type Unwrapped (MonoidalHashMap k a) = M.HashMap k a
        _Wrapped' = iso unpack pack
    

    Found in Data.Functor.Request from the package objective
    -- | Create a mealy machine from a time-varying action.
    --
    -- @ animate f ≡ accumulator (+) 0 >~~> liftO (accept f)@
    --
    animate :: (Applicative m, Num t) => (t -> m a) -> Object (Request t a) m
    animate f = go 0 where
      go t = mealy $ \dt -> flip (,) (go (t + dt)) <$> f t
    {-# INLINE animate #-}
    
    -- | Like 'animate', but the life is limited.
    transit :: (Alternative m, Fractional t, Ord t) => t -> (t -> m a) -> Object (Request t a) m
    transit len f = animate go where
      go t
        | t >= len = empty
        | otherwise = f (t / len)
    {-# INLINE transit #-}
    

    Found in Data.Functor.Request from the package objective
    {-# INLINE request #-}
    
    -- | Handle a 'Request', smashing the continuation.
    accept :: Functor m => (a -> m b) -> Request a b r -> m r
    accept f = \(Request a cont) -> cont <$> f a
    {-# INLINE accept #-}
    
    -- | Add a step as a mealy machine
    mealy :: Functor m => (a -> m (b, Object (Request a b) m)) -> Object (Request a b) m
    mealy f = Object $ \(Request a cont) -> first cont <$> f a
    {-# INLINE mealy #-}
    
    -- | The flyweight object
    flyweight :: (Applicative m, Eq k, Hashable k) => (k -> m a) -> Object (Request k a) m
    flyweight f = go HM.empty where
      go m = mealy $ \k -> case HM.lookup k m of
        Just a -> pure (a, go m)
        Nothing -> (\a -> (a, go $ HM.insert k a m)) <$> f k
    {-# INLINE flyweight #-}
    

    Found in Control.Once.Internal from the package once
    import Control.Monad
    
    once0 :: IO a -> IO (IO a)
    once0 act = do
        ref <- newIORef Nothing
        pure $ readIORef ref >>= \case
            Nothing -> do
                value <- act
                atomicWriteIORef ref (Just value)
                pure value
            Just value -> pure value
    
    once1 :: (Eq a, Hashable a) => (a -> IO b) -> IO (a -> IO b)
    once1 fn = do
        ref <- newIORef HM.empty
        pure $ \arg -> do
            action <- once0 $ fn arg
            let modify' map = case HM.lookup arg map of
                                  Just was -> (map, was)
                                  Nothing  -> (HM.insert arg action map, action)
    

    Found in Data.ProtocolBuffers.Decode from the package protobuf
    instance (GDecode x, GDecode y) => GDecode (x :+: y) where
      gdecode msg = L1 <$> gdecode msg <|> R1 <$> gdecode msg
    
    fieldDecode
      :: forall a b i n p . (DecodeWire a, Monoid a, KnownNat n)
      => (a -> b)
      -> HashMap Tag [WireField]
      -> Get (K1 i (Field n b) p)
    {-# INLINE fieldDecode #-}
    fieldDecode c msg =
      let tag = fromIntegral $ natVal (Proxy :: Proxy n)
      in case HashMap.lookup tag msg of
        Just val -> K1 . Field . c <$> foldMapM decodeWire val
        Nothing  -> empty
    
    instance (DecodeWire a, KnownNat n) => GDecode (K1 i (Field n (OptionalField (Last (Value a))))) where
      gdecode msg = fieldDecode Optional msg <|> pure (K1 mempty)
    
    instance (Enum a, KnownNat n) => GDecode (K1 i (Field n (RequiredField (Always (Enumeration a))))) where
    

    Found in Data.ProtocolBuffers.Decode from the package protobuf
    import Data.Proxy
    import Data.Serialize.Get
    import Data.Traversable (traverse)
    
    import GHC.Generics
    import GHC.TypeLits
    
    import Data.ProtocolBuffers.Types
    import Data.ProtocolBuffers.Wire
    
    -- |
    -- Decode a Protocol Buffers message.
    decodeMessage :: Decode a => Get a
    {-# INLINE decodeMessage #-}
    decodeMessage = decode =<< HashMap.map reverse <$> go HashMap.empty where
      go :: HashMap Tag [WireField] -> Get (HashMap Tag [WireField])
      go msg = do
        mfield <- Just <$> getWireField <|> return Nothing
        case mfield of
          Just v  -> go $! HashMap.insertWith (\(x:[]) xs -> x:xs) (wireFieldTag v) [v] msg
    

    Found in Rest.StringMap.HashMap.Strict from the package rest-stringmap
    fromHashMap :: HashMap a b -> StringHashMap a b
    fromHashMap = StringHashMap
    
    toHashMap :: StringHashMap a b -> HashMap a b
    toHashMap = unH
    
    fromList :: (Eq a, Hashable a) => [(a, b)] -> StringHashMap a b
    fromList = StringHashMap . H.fromList
    
    toList :: StringHashMap a b -> [(a, b)]
    toList = H.toList . unH
    
    -- | This is used with the assumption that a = b => f a = f b
    mapKeys :: (Hashable l, Eq l) => (k -> l) -> StringHashMap k v -> StringHashMap l v
    mapKeys f = StringHashMap . H.foldlWithKey' (\h k v -> H.insert (f k) v h) H.empty . unH
    
    -- | Base case since XmlPickler expects strings
    instance XmlPickler b => XmlPickler (StringHashMap String b) where
      xpickle = pickleStringMap fromList toList
    

    Found in RIO.HashMap from the package rio
    -- | Strict @Map@ with hashed keys. Import as:
    --
    -- > import qualified RIO.HashMap as HM
    module RIO.HashMap
      (
        Data.HashMap.Strict.HashMap
    
        -- * Construction
      , Data.HashMap.Strict.empty
      , Data.HashMap.Strict.singleton
    
        -- * Basic interface
      , Data.HashMap.Strict.null
      , Data.HashMap.Strict.size
    

    Found in Database.Selda.Backend.Internal from the package selda
      , connStmts :: !(IORef (M.HashMap StmtID SeldaStmt))
    
        -- | Is the connection closed?
      , connClosed :: !(IORef Bool)
    
        -- | Lock to prevent this connection from being used concurrently by
        --   multiple invocations of 'runSeldaT'.
      , connLock :: !(MVar ())
    }
    
    -- | Create a new Selda connection for the given backend and database
    --   identifier string.
    newConnection :: MonadIO m => SeldaBackend -> Text -> m SeldaConnection
    newConnection back dbid =
      liftIO $ SeldaConnection back dbid <$> newIORef M.empty
                                         <*> newIORef False
                                         <*> newMVar ()
    
    -- | Get all statements and their corresponding identifiers for the current
    --   connection.
    

    Found in Servant.Docs.Internal from the package servant-docs
    -- | Default sample Generic-based inputs/outputs.
    defaultSamples :: forall a. (Generic a, GToSample (Rep a)) => Proxy a -> [(Text, a)]
    defaultSamples _ = Omega.runOmega $ second to <$> gtoSamples (Proxy :: Proxy (Rep a))
    
    -- | @'ToSample'@ for Generics.
    --
    -- The use of @'Omega'@ allows for more productive sample generation.
    class GToSample t where
      gtoSamples :: proxy t -> Omega.Omega (Text, t x)
    
    instance GToSample U1 where
      gtoSamples _ = Omega.each (singleSample U1)
    
    instance GToSample V1 where
      gtoSamples _ = empty
    
    instance (GToSample p, GToSample q) => GToSample (p :*: q) where
      gtoSamples _ = render <$> ps <*> qs
        where
          ps = gtoSamples (Proxy :: Proxy p)
    

    Found in Servant.Docs.Internal from the package servant-docs
    -- 'toSample': it lets you specify different responses along with
    -- some context (as 'Text') that explains when you're supposed to
    -- get the corresponding response.
    class ToSample a where
      toSamples :: Proxy a -> [(Text, a)]
      default toSamples :: (Generic a, GToSample (Rep a)) => Proxy a -> [(Text, a)]
      toSamples = defaultSamples
    
    -- | Sample input or output (if there is at least one).
    toSample :: forall a. ToSample a => Proxy a -> Maybe a
    toSample _ = snd <$> listToMaybe (toSamples (Proxy :: Proxy a))
    
    -- | No samples.
    noSamples :: [(Text, a)]
    noSamples = empty
    
    -- | Single sample without description.
    singleSample :: a -> [(Text, a)]
    singleSample x = [("", x)]
    

    Found in Web.ServerSession.Core.Internal from the package serversession
      -- considered @empty@.
      --
      -- This is used to avoid storing empty session data if at all
      -- possible.  Always returning @False@ will disable the
      -- optimization but won't have any other adverse effects.
      isDecomposedEmpty :: proxy sess -> Decomposed sess -> Bool
    
    
    -- | A 'SessionMap' decomposes into a 'SessionMap' minus the keys
    -- that were removed.  The auth key is added back when
    -- recomposing.
    instance IsSessionData SessionMap where
      type Decomposed SessionMap = SessionMap
    
      emptySession = SessionMap HM.empty
    
      isSameDecomposed _ = (==)
    
      decomposeSession authKey_ (SessionMap sm1) =
        let authId = HM.lookup authKey_ sm1
    

    Found in Web.ServerSession.Core.StorageTests from the package serversession
            run (getSession storage sid) `shouldReturn` Just s2
        -- End of call to 'parallel'
    
      -- Size and representation limits (not tested in parallel)
      let trySessionMap vals = do
            sid <- generateSessionId gen
            now <- TI.getCurrentTime
            let session = Session
                  { sessionKey        = sid
                  , sessionAuthId     = Nothing
                  , sessionData       = SessionMap $ HM.fromList vals
                  , sessionCreatedAt  = now
                  , sessionAccessedAt = now
                  }
                ver2 = session { sessionData = SessionMap HM.empty }
            run (getSession storage sid) `shouldReturn` Nothing
            run (insertSession storage session)
            run (getSession storage sid) `shouldReturn` (Just session)
            run (replaceSession storage ver2)
            run (getSession storage sid) `shouldReturn` (Just ver2)
    

    Found in Xmlbf from the package xmlbf
    instance MonadFail Parser where
      fail e = Parser (\_ -> Left e)
    
    -- | Backtracks.
    instance Alternative Parser where
      {-# INLINE empty #-}
      empty = Parser (\_ -> Left "empty")
      {-# INLINE (<|>) #-}
      Parser a <|> Parser b = Parser (\s -> either (\_ -> b s) Right (a s))
    
    -- | Backtracks.
    instance MonadPlus Parser where
      {-# INLINE mzero #-}
      mzero = empty
      {-# INLINE mplus #-}
      mplus = (<|>)
    
    --------------------------------------------------------------------------------
    -- Some parsers
    

    Found in Xmlbf from the package xmlbf
      {-# INLINE return #-}
      return = pure
      {-# INLINE (>>=) #-}
      Parser ga >>= k = Parser $ \s0 -> do
        (a, s1) <- ga s0
        unParser (k a) s1
      fail e = Parser (\_ -> Left e)
    
    instance MonadFail Parser where
      fail e = Parser (\_ -> Left e)
    
    -- | Backtracks.
    instance Alternative Parser where
      {-# INLINE empty #-}
      empty = Parser (\_ -> Left "empty")
      {-# INLINE (<|>) #-}
      Parser a <|> Parser b = Parser (\s -> either (\_ -> b s) Right (a s))
    
    -- | Backtracks.
    instance MonadPlus Parser where
    

    Found in Xmlbf from the package xmlbf
    instance Monad Parser where
      {-# INLINE return #-}
      return = pure
      {-# INLINE (>>=) #-}
      Parser ga >>= k = Parser $ \s0 -> do
        (a, s1) <- ga s0
        unParser (k a) s1
      fail e = Parser (\_ -> Left e)
    
    instance MonadFail Parser where
      fail e = Parser (\_ -> Left e)
    
    -- | Backtracks.
    instance Alternative Parser where
      {-# INLINE empty #-}
      empty = Parser (\_ -> Left "empty")
      {-# INLINE (<|>) #-}
      Parser a <|> Parser b = Parser (\s -> either (\_ -> b s) Right (a s))
    
    -- | Backtracks.
    

    Found in Xmlbf from the package xmlbf
    import qualified Data.ByteString.Builder.Prim as BBP
    import qualified Data.Char as Char
    import Data.Foldable (for_, toList)
    import Data.Functor.Identity (Identity(Identity), runIdentity)
    import qualified Data.HashMap.Strict as HM
    import Data.Monoid ((<>))
    import Data.Sequence (Seq)
    import qualified Data.Sequence as Seq
    import Data.String (IsString(fromString))
    import qualified Data.Text as T
    import qualified Data.Text.Encoding as T
    import Data.Typeable (Typeable, typeRep, tyConName, typeRepTyCon)
    import Data.Traversable (for)
    import Data.Word (Word8)
    import Control.Applicative (Alternative(empty, (<|>)))
    import Control.Monad (MonadPlus(mplus, mzero), join, guard)
    import Control.Monad.Fail (MonadFail(fail))
    import qualified Text.Read
    
    --------------------------------------------------------------------------------
    

    filter See 57 Occurences [+] Collapse [-]
    Found in Data.Aeson.Diff from the package aeson-diff
                -- Deletions
                del_keys :: [Text]
                del_keys = filter (not . (`elem` k2)) k1
                deletions :: [Operation]
                deletions = concatMap
                    (\k -> del cfg (Pointer [OKey k]) (fromJust $ HM.lookup k o1))
                    del_keys
                -- Insertions
                ins_keys = filter (not . (`elem` k1)) k2
                insertions :: [Operation]
                insertions = concatMap
                    (\k -> ins cfg (Pointer [OKey k]) (fromJust $ HM.lookup k o2))
                    ins_keys
                -- Changes
                chg_keys = filter (`elem` k2) k1
                changes :: [Operation]
                changes = concatMap
                    (\k -> worker (Pointer [OKey k])
                        (fromJust $ HM.lookup k o1)
                        (fromJust $ HM.lookup k o2))
    

    Found in Data.Aeson.Diff from the package aeson-diff
        -- Walk the keys in two objects, producing a 'Patch'.
        workObject :: Pointer -> Object -> Object -> [Operation]
        workObject path o1 o2 =
            let k1 = HM.keys o1
                k2 = HM.keys o2
                -- Deletions
                del_keys :: [Text]
                del_keys = filter (not . (`elem` k2)) k1
                deletions :: [Operation]
                deletions = concatMap
                    (\k -> del cfg (Pointer [OKey k]) (fromJust $ HM.lookup k o1))
                    del_keys
                -- Insertions
                ins_keys = filter (not . (`elem` k1)) k2
                insertions :: [Operation]
                insertions = concatMap
                    (\k -> ins cfg (Pointer [OKey k]) (fromJust $ HM.lookup k o2))
                    ins_keys
                -- Changes
    

    Found in Data.Aeson.Diff from the package aeson-diff
            -- For structured values of the same type, walk them.
            (Array a1,  Array a2)  -> check (a1 == a2) $ workArray  p a1 a2
            (Object o1, Object o2) -> check (o1 == o2) $ workObject p o1 o2
    
            -- For values of different types, replace v1 with v2.
            _                      -> rep cfg p v2
    
        -- Walk the keys in two objects, producing a 'Patch'.
        workObject :: Pointer -> Object -> Object -> [Operation]
        workObject path o1 o2 =
            let k1 = HM.keys o1
                k2 = HM.keys o2
                -- Deletions
                del_keys :: [Text]
                del_keys = filter (not . (`elem` k2)) k1
                deletions :: [Operation]
                deletions = concatMap
                    (\k -> del cfg (Pointer [OKey k]) (fromJust $ HM.lookup k o1))
                    del_keys
                -- Insertions
    

    Found in Country.Unexposed.Names from the package country
    englishCountryNamesText = runST $ do
      m <- newArray numberOfPossibleCodes unnamed
      mapM_ (\(ix,name,_,_) -> writeArray m (word16ToInt ix) name) countryNameQuads
      unsafeFreezeArray m
    {-# NOINLINE englishCountryNamesText #-}
    
    englishIdentifierNamesText :: Array Text
    englishIdentifierNamesText = runST $ do
      m <- newArray numberOfPossibleCodes unnamed
      mapM_ (\(ix,name,_,_) -> writeArray m (word16ToInt ix) (toIdentifier name)) countryNameQuads
      unsafeFreezeArray m
    {-# NOINLINE englishIdentifierNamesText #-}
    
    toIdentifier :: Text -> Text
    toIdentifier t = case (T.uncons . T.filter isAlpha . slowToTitle) t of
      Nothing -> T.empty
      Just (b,bs) -> T.cons (toLower b) bs
    
    
    unnamed :: Text
    

    Found in Caching.ExpiringCacheMap.HashECM from the package expiring-cache-map
          (ret, do_again) <- det retr_state maps mapsize uses' incr'
          if do_again
            then do let (CacheState (retr_state', maps', mapsize', uses'', incr''), _) = ret
                        uses''' = updateUses uses'' id incr'' compactlistsize mnub
                    (ret', _) <- det retr_state' maps' mapsize' uses''' incr''
                    return ret'
            else return ret
        
        det retr_state maps mapsize uses' incr' =
          detECM (HM.lookup id maps) retr_state (retr retr_state id)
            ( (\time_r -> HM.insert id time_r maps),
              (\time_r keepuses -> HM.insert id time_r $! HM.intersection maps $ HM.fromList keepuses),
              mnub, minimumkeep, removalsize )
            gettime
            HM.filter
            mapsize HM.size
            uses' incr' timecheckmodulo maps
    
    
    getValReqState :: (Monad m, Eq k, Hashable k) => ECM m mv s HM.HashMap k v -> k -> m (Maybe s)
    

    Found in Data.FuzzySet.Internal from the package fuzzyset
    import Data.HashMap.Strict             ( HashMap, alter, empty, elems, foldrWithKey )
    import Data.Maybe                      ( fromMaybe )
    import Data.List                       ( sortBy )
    import Data.Text                       ( Text )
    import Prelude.Unicode
    
    import qualified Data.HashMap.Strict   as HashMap
    import qualified Data.Text             as Text
    import qualified Data.Vector           as Vector
    
    getMatch  GetContext  Size  [(Double, Text)]
    getMatch GetContext{..} size = match <$$> filtered
      where
        match α = set ^._exactSet.ix α
        filtered = filter ((<) minScore  fst) sorted
        μ p = p & _1.~ distance (p ^._2) key
        sorted = sortBy (flip compare `on` fst) $
            let rs = results GetContext{..} size
             in if set ^._useLevenshtein
                    then take 50 (μ <$> rs)
    

    Found in Data.FuzzySet.Util from the package fuzzyset
    import Data.Char                       ( isAlphaNum, isSpace )
    import Data.HashMap.Strict             ( HashMap, empty )
    import Data.Text                       ( Text, cons, snoc )
    import Data.Text.Metrics
    import Prelude.Unicode
    
    import qualified Data.Text             as Text
    
    -- | Normalize the input by
    --
    --     * removing non-word characters, except for spaces and commas; and
    --     * converting alphabetic characters to lowercase.
    normalized  Text  Text
    normalized = Text.filter word  Text.toLower
      where
        word ch
          | isAlphaNum ch = True
          | isSpace    ch = True
          | () ','    ch = True
    

    Found in Text.Glabrous from the package glabrous
        trans (Tag k)     = T.concat ["{{",k,"}}"]
    
    -- | Output the content of the given 'Template'
    -- with all its 'Tag's removed.
    toFinalText :: Template -> T.Text
    toFinalText Template{..} =
      foldl trans T.empty content
      where
        trans o (Literal l) = o `T.append` l
        trans o (Tag _) = o
    
    -- | Get the list of 'Tag's in the given 'Template'.
    tagsOf :: Template -> [Tag]
    tagsOf Template{..} =
      (\(Tag k) -> k) <$> filter isTag content
      where
        isTag (Tag _) = True
        isTag _       = False
    
    tagsRename :: [(T.Text,T.Text)] -> Template -> Template
    

    Found in Text.Glabrous from the package glabrous
    -- @
    --
    initContextFile :: FilePath -> Context -> IO ()
    initContextFile f Context {..} = L.writeFile f $
      encodePretty Context { variables = H.map (const T.empty) variables }
    
    -- | Build 'Just' a (sub)'Context' made of unset variables
    -- of the given context, or 'Nothing'.
    --
    -- >λ>unsetContext context
    -- >Just (Context {variables = fromList [("name","")]})
    --
    unsetContext :: Context -> Maybe Context
    unsetContext Context {..} = do
      let vs = H.filter (== T.empty) variables
      guard (vs /= H.empty)
      return Context { variables = vs }
    
    -- | 'True' if the all variables of
    -- the given 'Context' are not empty.
    

    Found in Language.Haskell.LSP.TH.DataTypesJSON from the package haskell-lsp-types
    platformAwareFilePathToUri systemOS fp = Uri . T.pack . show $ URI
      { uriScheme = fileScheme
      , uriAuthority = Just $ URIAuth "" "" ""
      , uriPath = platformAdjustToUriPath systemOS fp
      , uriQuery = ""
      , uriFragment = ""
      }
    
    platformAdjustToUriPath :: SystemOS -> FilePath -> String
    platformAdjustToUriPath systemOS srcPath =
      if systemOS /= windowsOS then srcPath
        else let
          drive:rest = FPW.splitDirectories srcPath
          leaveCharUnescaped = (/= ':')
          removePathSeparator = filter (not . FPW.isPathSeparator)
          escapedDrive = removePathSeparator $ escapeURIString leaveCharUnescaped drive
          in '/' : FPP.joinPath (escapedDrive : rest)
    
    -- ---------------------------------------------------------------------
    

    Found in Haxl.Core.Stats from the package haxl
        [ "["
        ++ [
          if fetchWasRunning rs
              (minStartTime + (t - 1) * usPerDash)
              (minStartTime + t * usPerDash)
            then '*'
            else '-'
          | t <- [1..numDashes]
          ]
        ++ "] " ++ show i ++ " - " ++ ppFetchStats rs
        | (i, rs) <- zip [(1::Int)..] validFetchStats ]
      where
        isFetchStats FetchStats{} = True
        isFetchStats _ = False
        validFetchStats = filter isFetchStats (reverse rss)
        numDashes = 50
        minStartTime = fetchStart $ minimumBy (comparing fetchStart) validFetchStats
        lastFs = maximumBy (comparing (\fs -> fetchStart fs + fetchDuration fs))
          validFetchStats
        usPerDash = (fetchStart lastFs + fetchDuration lastFs - minStartTime)
    

    Found in Network.Http.Internal from the package http-common
        This is a fair bit of trouble just to avoid using a typedef here.
        Probably worth it, though; every other HTTP client library out there
        exposes the gory details of the underlying map implementation, and
        to use it you need to figure out all kinds of crazy imports. Indeed,
        this code used here in the Show instance for debugging has been
        copied & pasted around various projects of mine since I started
        writing Haskell. It's quite tedious, and very arcane! So, wrap it
        up.
    -}
    newtype Headers = Wrap {
        unWrap :: HashMap (CI ByteString) ByteString
    } deriving (Eq)
    
    instance Show Headers where
        show x = S.unpack $ S.filter (/= '\r') $ Builder.toByteString $ joinHeaders $ unWrap x
    
    joinHeaders :: HashMap (CI ByteString) ByteString -> Builder
    joinHeaders m = foldrWithKey combine mempty m
    
    combine :: CI ByteString -> ByteString -> Builder -> Builder
    

    Found in Network.Http.Internal from the package http-common
    -- server.
    --
    data Response
        = Response {
            pStatusCode       :: !StatusCode,
            pStatusMsg        :: !ByteString,
            pTransferEncoding :: !TransferEncoding,
            pContentEncoding  :: !ContentEncoding,
            pContentLength    :: !(Maybe Int64),
            pHeaders          :: !Headers
        }
    
    instance Show Response where
        show p =     {-# SCC "Response.show" #-}
            S.unpack $ S.filter (/= '\r') $ Builder.toByteString $ composeResponseBytes p
    
    
    data TransferEncoding = None | Chunked
    
    data ContentEncoding = Identity | Gzip | Deflate
    

    Found in Network.Http.Internal from the package http-common
    -- to override the value inherited from the @Connection@).
    --
    data Request
        = Request {
            qMethod  :: !Method,
            qHost    :: !(Maybe ByteString),
            qPath    :: !ByteString,
            qBody    :: !EntityBody,
            qExpect  :: !ExpectMode,
            qHeaders :: !Headers
        } deriving (Eq)
    
    instance Show Request where
        show q = {-# SCC "Request.show" #-}
            S.unpack $ S.filter (/= '\r') $ Builder.toByteString $ composeRequestBytes q "<default>"
    
    
    data EntityBody = Empty | Chunking | Static Int64 deriving (Show, Eq, Ord)
    
    data ExpectMode = Normal | Continue deriving (Show, Eq, Ord)
    

    Found in Crypto.JOSE.Header from the package jose
    -- | Return the encoded protected parameters
    --
    protectedParamsEncoded
      :: (HasParams a, ProtectionIndicator p)
      => a p -> L.ByteString
    protectedParamsEncoded =
      maybe mempty (unpad . B64UL.encode . encode) . protectedParams
    
    -- | Return unprotected params as a JSON 'Value' (always an object)
    --
    unprotectedParams
      :: (HasParams a, ProtectionIndicator p)
      => a p -> Maybe Value {- ^ Object -}
    unprotectedParams h =
      case (map snd . filter (not . fst) . params) h of
        [] -> Nothing
        xs -> Just (object xs)
    
    -- | Whether a header is protected or unprotected
    --
    

    Found in Crypto.JOSE.Header from the package jose
    -- the target type.  (This allows the parsing of the "crit" parameter
    -- to access "known extensions" understood by the target type.)
    --
    parseParams
      :: forall a p. (HasParams a, ProtectionIndicator p)
      => Maybe Object -- ^ protected header
      -> Maybe Object -- ^ unprotected header
      -> Parser (a p)
    parseParams = parseParamsFor (Proxy :: Proxy a)
    
    protectedParams
      :: (HasParams a, ProtectionIndicator p)
      => a p -> Maybe Value {- ^ Object -}
    protectedParams h =
      case (map snd . filter fst . params) h of
        [] -> Nothing
        xs -> Just (object xs)
    
    -- | Return the encoded protected parameters
    --
    

    Found in Crypto.JOSE.JWS from the package jose
        algs = conf ^. algorithms
        policy :: ValidationPolicy
        policy = conf ^. validationPolicy
        shouldValidateSig = (`elem` algs) . view (header . alg . param)
        out = view recons p'
        applyPolicy AnyValidated xs =
          if or xs then pure out else throwError (review _JWSNoValidSignatures ())
        applyPolicy AllValidated [] = throwError (review _JWSNoSignatures ())
        applyPolicy AllValidated xs =
          if and xs then pure out else throwError (review _JWSInvalidSignature ())
        validate s =
          let h = view header s
          in anyOf (keysFor Verify h) ((== Right True) . verifySig p s) k
      in
        applyPolicy policy $ map validate $ filter shouldValidateSig $ toList sigs
    
    verifySig
      :: (HasJWSHeader a, HasParams a, ProtectionIndicator p)
      => Types.Base64Octets
      -> Signature p a
    

    Found in Data.Aeson.AutoType.Extract from the package json-autotype
    unifyTypes t           s         = typeAsSet t `unifyUnion` typeAsSet s
    
    -- | Unify sets of types (sets are union types of alternatives).
    unifyUnion :: Set Type -> Set Type -> Type
    unifyUnion u v = assertions $
                       union $ uSimple        `Set.union`
                               vSimple        `Set.union`
                               unifiedObjects `Set.union`
                               Set.singleton unifiedArray
      where
        -- We partition our types for easier unification into simple and compound
        (uSimple, uCompound) = Set.partition isSimple u
        (vSimple, vCompound) = Set.partition isSimple v
        assertions = assert (Set.null $ Set.filter (not . isArray) uArr) .
                     assert (Set.null $ Set.filter (not . isArray) vArr)
        -- then we partition compound typs into objects and arrays.
        -- Note that there should be no TUnion here, since we are inside a TUnion already.
        -- (That is reduced by @union@ smart costructor as superfluous.)
        (uObj, uArr)   = Set.partition isObject uCompound
        (vObj, vArr)   = Set.partition isObject vCompound
    

    Found in Data.Aeson.AutoType.Extract from the package json-autotype
    unifyTypes (TArray u) (TArray v) = TArray $ u `unifyTypes` v
    unifyTypes t           s         = typeAsSet t `unifyUnion` typeAsSet s
    
    -- | Unify sets of types (sets are union types of alternatives).
    unifyUnion :: Set Type -> Set Type -> Type
    unifyUnion u v = assertions $
                       union $ uSimple        `Set.union`
                               vSimple        `Set.union`
                               unifiedObjects `Set.union`
                               Set.singleton unifiedArray
      where
        -- We partition our types for easier unification into simple and compound
        (uSimple, uCompound) = Set.partition isSimple u
        (vSimple, vCompound) = Set.partition isSimple v
        assertions = assert (Set.null $ Set.filter (not . isArray) uArr) .
                     assert (Set.null $ Set.filter (not . isArray) vArr)
        -- then we partition compound typs into objects and arrays.
        -- Note that there should be no TUnion here, since we are inside a TUnion already.
        -- (That is reduced by @union@ smart costructor as superfluous.)
        (uObj, uArr)   = Set.partition isObject uCompound
    

    Found in Data.Aeson.AutoType.CodeGen.ElmFormat from the package json-autotype
            formatObjectType (normalizeTypeName name) typ
    
    -- | Normalize type name by:
    -- 1. Treating all characters that are not acceptable in Haskell variable name as end of word.
    -- 2. Capitalizing each word, but a first (camelCase).
    -- 3. Adding underscore if first character is non-alphabetic.
    -- 4. Escaping Haskell keywords if the whole identifier is such keyword.
    -- 5. If identifier is empty, then substituting "JsonEmptyKey" for its name.
    normalizeTypeName :: Text -> Text
    normalizeTypeName s  = ifEmpty "JsonEmptyKey"                  .
                           escapeKeywords                          .
                           escapeFirstNonAlpha                     .
                           Text.concat                             .
                           map capitalize                          .
                           filter     (not . Text.null)            .
                           Text.split (not . acceptableInVariable) $ s
      where
        ifEmpty x ""       = x
        ifEmpty _ nonEmpty = nonEmpty
        acceptableInVariable c = isAlpha c || isDigit c
    

    Found in Data.Aeson.AutoType.CodeGen.ElmFormat from the package json-autotype
    normalizeFieldName ::  Text -> Text -> Text
    normalizeFieldName identifier = escapeKeywords             .
                                    uncapitalize               .
                                    (normalizeTypeName identifier `Text.append`) .
                                    normalizeTypeName
    
    keywords ::  Set Text
    keywords = Set.fromList ["type", "alias", "exposing", "module", "class",
                             "where", "let", "do"]
    
    escapeKeywords ::  Text -> Text
    escapeKeywords k | k `Set.member` keywords = k `Text.append` "_"
    escapeKeywords k                           = k
    
    nonNullComponents = Set.toList . Set.filter (TNull /=)
    -- | Format the type within DeclM monad, that records
    -- the separate declarations on which this one is dependent.
    formatType :: Type -> DeclM Text
    formatType  TString                          = return "String"
    formatType  TNum                             = return "Float"
    

    Found in Data.Aeson.AutoType.CodeGen.HaskellFormat from the package json-autotype
            formatObjectType (normalizeTypeName name) typ
    
    -- | Normalize type name by:
    -- 1. Treating all characters that are not acceptable in Haskell variable name as end of word.
    -- 2. Capitalizing each word, but a first (camelCase).
    -- 3. Adding underscore if first character is non-alphabetic.
    -- 4. Escaping Haskell keywords if the whole identifier is such keyword.
    -- 5. If identifier is empty, then substituting "JsonEmptyKey" for its name.
    normalizeTypeName :: Text -> Text
    normalizeTypeName = ifEmpty "JsonEmptyKey"                  .
                        escapeKeywords                          .
                        escapeFirstNonAlpha                     .
                        Text.concat                             .
                        map capitalize                          .
                        filter     (not . Text.null)            .
                        Text.split (not . acceptableInVariable)
      where
        ifEmpty x ""       = x
        ifEmpty _ nonEmpty = nonEmpty
        acceptableInVariable c = isAlpha c || isDigit c
    

    Found in Data.Aeson.AutoType.CodeGen.HaskellFormat from the package json-autotype
    escapeKeywords k                           = k
    
    -- | Format the type within DeclM monad, that records
    -- the separate declarations on which this one is dependent.
    formatType :: Type -> DeclM Text
    formatType  TString                          = return "Text"
    formatType  TNum                             = return "Double"
    formatType  TBool                            = return "Bool"
    formatType (TLabel l)                        = return $ normalizeTypeName l
    formatType (TUnion u)                        = wrap <$> case length nonNull of
                                                              0 -> return emptyTypeRepr
                                                              1 -> formatType $ head nonNull
                                                              _ -> Text.intercalate ":|:" <$> mapM formatType nonNull
      where
        nonNull       = Set.toList $ Set.filter (TNull /=) u
        wrap                                :: Text -> Text
        wrap   inner  | TNull `Set.member` u = Text.concat ["(Maybe (", inner, "))"]
                      | otherwise            =                          inner
    formatType (TArray a)                        = do inner <- formatType a
                                                      return $ Text.concat ["[", inner, "]"]
    

    Found in Data.Aeson.AutoType.Extract from the package json-autotype
    unifyTypes t           s         = typeAsSet t `unifyUnion` typeAsSet s
    
    -- | Unify sets of types (sets are union types of alternatives).
    unifyUnion :: Set Type -> Set Type -> Type
    unifyUnion u v = assertions $
                       union $ uSimple        `Set.union`
                               vSimple        `Set.union`
                               unifiedObjects `Set.union`
                               Set.singleton unifiedArray
      where
        -- We partition our types for easier unification into simple and compound
        (uSimple, uCompound) = Set.partition isSimple u
        (vSimple, vCompound) = Set.partition isSimple v
        assertions = assert (Set.null $ Set.filter (not . isArray) uArr) .
                     assert (Set.null $ Set.filter (not . isArray) vArr)
        -- then we partition compound typs into objects and arrays.
        -- Note that there should be no TUnion here, since we are inside a TUnion already.
        -- (That is reduced by @union@ smart costructor as superfluous.)
        (uObj, uArr)   = Set.partition isObject uCompound
        (vObj, vArr)   = Set.partition isObject vCompound
    

    Found in Data.Aeson.AutoType.Extract from the package json-autotype
    unifyTypes (TArray u) (TArray v) = TArray $ u `unifyTypes` v
    unifyTypes t           s         = typeAsSet t `unifyUnion` typeAsSet s
    
    -- | Unify sets of types (sets are union types of alternatives).
    unifyUnion :: Set Type -> Set Type -> Type
    unifyUnion u v = assertions $
                       union $ uSimple        `Set.union`
                               vSimple        `Set.union`
                               unifiedObjects `Set.union`
                               Set.singleton unifiedArray
      where
        -- We partition our types for easier unification into simple and compound
        (uSimple, uCompound) = Set.partition isSimple u
        (vSimple, vCompound) = Set.partition isSimple v
        assertions = assert (Set.null $ Set.filter (not . isArray) uArr) .
                     assert (Set.null $ Set.filter (not . isArray) vArr)
        -- then we partition compound typs into objects and arrays.
        -- Note that there should be no TUnion here, since we are inside a TUnion already.
        -- (That is reduced by @union@ smart costructor as superfluous.)
        (uObj, uArr)   = Set.partition isObject uCompound
    

    Found in Data.Aeson.AutoType.Split from the package json-autotype
    allLabels :: Type -> [Text]
    allLabels = flip go []
      where
        go (TLabel l) ls = l:ls
        go (TArray t) ls = go t ls
        go (TUnion u) ls = Set.foldr go ls          u
        go (TObj   o) ls = Map.foldr go ls $ unDict o
        go _other     ls = ls
    
    -- * Finding candidates for extra unifications
    -- | For a given splitted types, it returns candidates for extra
    -- unifications.
    unificationCandidates :: Map.HashMap t Type -> [[t]]
    unificationCandidates = Map.elems             .
                            Map.filter candidates .
                            Map.fromListWith (++) .
                            concatMap entry       .
                            Map.toList
      where
        -- | Candidate entry has to have at least two candidates, so that unification makes sense
    

    Found in Data.Aeson.AutoType.Split from the package json-autotype
    allLabels :: Type -> [Text]
    allLabels = flip go []
      where
        go (TLabel l) ls = l:ls
        go (TArray t) ls = go t ls
        go (TUnion u) ls = Set.foldr go ls          u
        go (TObj   o) ls = Map.foldr go ls $ unDict o
        go _other     ls = ls
    
    -- * Finding candidates for extra unifications
    -- | For a given splitted types, it returns candidates for extra
    -- unifications.
    unificationCandidates :: Map.HashMap t Type -> [[t]]
    unificationCandidates = Map.elems             .
                            Map.filter candidates .
                            Map.fromListWith (++) .
                            concatMap entry       .
                            Map.toList
      where
        -- | Candidate entry has to have at least two candidates, so that unification makes sense
    

    Found in Data.Aeson.AutoType.Extract from the package json-autotype
    unifyTypes t           s         = typeAsSet t `unifyUnion` typeAsSet s
    
    -- | Unify sets of types (sets are union types of alternatives).
    unifyUnion :: Set Type -> Set Type -> Type
    unifyUnion u v = assertions $
                       union $ uSimple        `Set.union`
                               vSimple        `Set.union`
                               unifiedObjects `Set.union`
                               Set.singleton unifiedArray
      where
        -- We partition our types for easier unification into simple and compound
        (uSimple, uCompound) = Set.partition isSimple u
        (vSimple, vCompound) = Set.partition isSimple v
        assertions = assert (Set.null $ Set.filter (not . isArray) uArr) .
                     assert (Set.null $ Set.filter (not . isArray) vArr)
        -- then we partition compound typs into objects and arrays.
        -- Note that there should be no TUnion here, since we are inside a TUnion already.
        -- (That is reduced by @union@ smart costructor as superfluous.)
        (uObj, uArr)   = Set.partition isObject uCompound
        (vObj, vArr)   = Set.partition isObject vCompound
    

    Found in Data.Aeson.AutoType.Extract from the package json-autotype
    unifyTypes (TArray u) (TArray v) = TArray $ u `unifyTypes` v
    unifyTypes t           s         = typeAsSet t `unifyUnion` typeAsSet s
    
    -- | Unify sets of types (sets are union types of alternatives).
    unifyUnion :: Set Type -> Set Type -> Type
    unifyUnion u v = assertions $
                       union $ uSimple        `Set.union`
                               vSimple        `Set.union`
                               unifiedObjects `Set.union`
                               Set.singleton unifiedArray
      where
        -- We partition our types for easier unification into simple and compound
        (uSimple, uCompound) = Set.partition isSimple u
        (vSimple, vCompound) = Set.partition isSimple v
        assertions = assert (Set.null $ Set.filter (not . isArray) uArr) .
                     assert (Set.null $ Set.filter (not . isArray) vArr)
        -- then we partition compound typs into objects and arrays.
        -- Note that there should be no TUnion here, since we are inside a TUnion already.
        -- (That is reduced by @union@ smart costructor as superfluous.)
        (uObj, uArr)   = Set.partition isObject uCompound
    

    Found in Data.Aeson.AutoType.CodeGen.HaskellFormat from the package json-autotype
            formatObjectType (normalizeTypeName name) typ
    
    -- | Normalize type name by:
    -- 1. Treating all characters that are not acceptable in Haskell variable name as end of word.
    -- 2. Capitalizing each word, but a first (camelCase).
    -- 3. Adding underscore if first character is non-alphabetic.
    -- 4. Escaping Haskell keywords if the whole identifier is such keyword.
    -- 5. If identifier is empty, then substituting "JsonEmptyKey" for its name.
    normalizeTypeName :: Text -> Text
    normalizeTypeName = ifEmpty "JsonEmptyKey"                  .
                        escapeKeywords                          .
                        escapeFirstNonAlpha                     .
                        Text.concat                             .
                        map capitalize                          .
                        filter     (not . Text.null)            .
                        Text.split (not . acceptableInVariable)
      where
        ifEmpty x ""       = x
        ifEmpty _ nonEmpty = nonEmpty
        acceptableInVariable c = isAlpha c || isDigit c
    

    Found in Data.Aeson.AutoType.CodeGen.HaskellFormat from the package json-autotype
    escapeKeywords k                           = k
    
    -- | Format the type within DeclM monad, that records
    -- the separate declarations on which this one is dependent.
    formatType :: Type -> DeclM Text
    formatType  TString                          = return "Text"
    formatType  TNum                             = return "Double"
    formatType  TBool                            = return "Bool"
    formatType (TLabel l)                        = return $ normalizeTypeName l
    formatType (TUnion u)                        = wrap <$> case length nonNull of
                                                              0 -> return emptyTypeRepr
                                                              1 -> formatType $ head nonNull
                                                              _ -> Text.intercalate ":|:" <$> mapM formatType nonNull
      where
        nonNull       = Set.toList $ Set.filter (TNull /=) u
        wrap                                :: Text -> Text
        wrap   inner  | TNull `Set.member` u = Text.concat ["(Maybe (", inner, "))"]
                      | otherwise            =                          inner
    formatType (TArray a)                        = do inner <- formatType a
                                                      return $ Text.concat ["[", inner, "]"]
    

    Found in Data.Aeson.AutoType.CodeGen.ElmFormat from the package json-autotype
            formatObjectType (normalizeTypeName name) typ
    
    -- | Normalize type name by:
    -- 1. Treating all characters that are not acceptable in Haskell variable name as end of word.
    -- 2. Capitalizing each word, but a first (camelCase).
    -- 3. Adding underscore if first character is non-alphabetic.
    -- 4. Escaping Haskell keywords if the whole identifier is such keyword.
    -- 5. If identifier is empty, then substituting "JsonEmptyKey" for its name.
    normalizeTypeName :: Text -> Text
    normalizeTypeName s  = ifEmpty "JsonEmptyKey"                  .
                           escapeKeywords                          .
                           escapeFirstNonAlpha                     .
                           Text.concat                             .
                           map capitalize                          .
                           filter     (not . Text.null)            .
                           Text.split (not . acceptableInVariable) $ s
      where
        ifEmpty x ""       = x
        ifEmpty _ nonEmpty = nonEmpty
        acceptableInVariable c = isAlpha c || isDigit c
    

    Found in Data.Aeson.AutoType.CodeGen.ElmFormat from the package json-autotype
    normalizeFieldName ::  Text -> Text -> Text
    normalizeFieldName identifier = escapeKeywords             .
                                    uncapitalize               .
                                    (normalizeTypeName identifier `Text.append`) .
                                    normalizeTypeName
    
    keywords ::  Set Text
    keywords = Set.fromList ["type", "alias", "exposing", "module", "class",
                             "where", "let", "do"]
    
    escapeKeywords ::  Text -> Text
    escapeKeywords k | k `Set.member` keywords = k `Text.append` "_"
    escapeKeywords k                           = k
    
    nonNullComponents = Set.toList . Set.filter (TNull /=)
    -- | Format the type within DeclM monad, that records
    -- the separate declarations on which this one is dependent.
    formatType :: Type -> DeclM Text
    formatType  TString                          = return "String"
    formatType  TNum                             = return "Float"
    

    Found in Data.Aeson.AutoType.Extract from the package json-autotype
    unifyTypes t           s         = typeAsSet t `unifyUnion` typeAsSet s
    
    -- | Unify sets of types (sets are union types of alternatives).
    unifyUnion :: Set Type -> Set Type -> Type
    unifyUnion u v = assertions $
                       union $ uSimple        `Set.union`
                               vSimple        `Set.union`
                               unifiedObjects `Set.union`
                               Set.singleton unifiedArray
      where
        -- We partition our types for easier unification into simple and compound
        (uSimple, uCompound) = Set.partition isSimple u
        (vSimple, vCompound) = Set.partition isSimple v
        assertions = assert (Set.null $ Set.filter (not . isArray) uArr) .
                     assert (Set.null $ Set.filter (not . isArray) vArr)
        -- then we partition compound typs into objects and arrays.
        -- Note that there should be no TUnion here, since we are inside a TUnion already.
        -- (That is reduced by @union@ smart costructor as superfluous.)
        (uObj, uArr)   = Set.partition isObject uCompound
        (vObj, vArr)   = Set.partition isObject vCompound
    

    Found in Data.Aeson.AutoType.Extract from the package json-autotype
    unifyTypes (TArray u) (TArray v) = TArray $ u `unifyTypes` v
    unifyTypes t           s         = typeAsSet t `unifyUnion` typeAsSet s
    
    -- | Unify sets of types (sets are union types of alternatives).
    unifyUnion :: Set Type -> Set Type -> Type
    unifyUnion u v = assertions $
                       union $ uSimple        `Set.union`
                               vSimple        `Set.union`
                               unifiedObjects `Set.union`
                               Set.singleton unifiedArray
      where
        -- We partition our types for easier unification into simple and compound
        (uSimple, uCompound) = Set.partition isSimple u
        (vSimple, vCompound) = Set.partition isSimple v
        assertions = assert (Set.null $ Set.filter (not . isArray) uArr) .
                     assert (Set.null $ Set.filter (not . isArray) vArr)
        -- then we partition compound typs into objects and arrays.
        -- Note that there should be no TUnion here, since we are inside a TUnion already.
        -- (That is reduced by @union@ smart costructor as superfluous.)
        (uObj, uArr)   = Set.partition isObject uCompound
    

    Found in Data.Aeson.AutoType.Split from the package json-autotype
    allLabels :: Type -> [Text]
    allLabels = flip go []
      where
        go (TLabel l) ls = l:ls
        go (TArray t) ls = go t ls
        go (TUnion u) ls = Set.foldr go ls          u
        go (TObj   o) ls = Map.foldr go ls $ unDict o
        go _other     ls = ls
    
    -- * Finding candidates for extra unifications
    -- | For a given splitted types, it returns candidates for extra
    -- unifications.
    unificationCandidates :: Map.HashMap t Type -> [[t]]
    unificationCandidates = Map.elems             .
                            Map.filter candidates .
                            Map.fromListWith (++) .
                            concatMap entry       .
                            Map.toList
      where
        -- | Candidate entry has to have at least two candidates, so that unification makes sense
    

    Found in Data.Aeson.AutoType.CodeGen.HaskellFormat from the package json-autotype
            formatObjectType (normalizeTypeName name) typ
    
    -- | Normalize type name by:
    -- 1. Treating all characters that are not acceptable in Haskell variable name as end of word.
    -- 2. Capitalizing each word, but a first (camelCase).
    -- 3. Adding underscore if first character is non-alphabetic.
    -- 4. Escaping Haskell keywords if the whole identifier is such keyword.
    -- 5. If identifier is empty, then substituting "JsonEmptyKey" for its name.
    normalizeTypeName :: Text -> Text
    normalizeTypeName = ifEmpty "JsonEmptyKey"                  .
                        escapeKeywords                          .
                        escapeFirstNonAlpha                     .
                        Text.concat                             .
                        map capitalize                          .
                        filter     (not . Text.null)            .
                        Text.split (not . acceptableInVariable)
      where
        ifEmpty x ""       = x
        ifEmpty _ nonEmpty = nonEmpty
        acceptableInVariable c = isAlpha c || isDigit c
    

    Found in Data.Aeson.AutoType.CodeGen.HaskellFormat from the package json-autotype
    escapeKeywords k                           = k
    
    -- | Format the type within DeclM monad, that records
    -- the separate declarations on which this one is dependent.
    formatType :: Type -> DeclM Text
    formatType  TString                          = return "Text"
    formatType  TNum                             = return "Double"
    formatType  TBool                            = return "Bool"
    formatType (TLabel l)                        = return $ normalizeTypeName l
    formatType (TUnion u)                        = wrap <$> case length nonNull of
                                                              0 -> return emptyTypeRepr
                                                              1 -> formatType $ head nonNull
                                                              _ -> Text.intercalate ":|:" <$> mapM formatType nonNull
      where
        nonNull       = Set.toList $ Set.filter (TNull /=) u
        wrap                                :: Text -> Text
        wrap   inner  | TNull `Set.member` u = Text.concat ["(Maybe (", inner, "))"]
                      | otherwise            =                          inner
    formatType (TArray a)                        = do inner <- formatType a
                                                      return $ Text.concat ["[", inner, "]"]
    

    Found in Data.Aeson.AutoType.CodeGen.ElmFormat from the package json-autotype
            formatObjectType (normalizeTypeName name) typ
    
    -- | Normalize type name by:
    -- 1. Treating all characters that are not acceptable in Haskell variable name as end of word.
    -- 2. Capitalizing each word, but a first (camelCase).
    -- 3. Adding underscore if first character is non-alphabetic.
    -- 4. Escaping Haskell keywords if the whole identifier is such keyword.
    -- 5. If identifier is empty, then substituting "JsonEmptyKey" for its name.
    normalizeTypeName :: Text -> Text
    normalizeTypeName s  = ifEmpty "JsonEmptyKey"                  .
                           escapeKeywords                          .
                           escapeFirstNonAlpha                     .
                           Text.concat                             .
                           map capitalize                          .
                           filter     (not . Text.null)            .
                           Text.split (not . acceptableInVariable) $ s
      where
        ifEmpty x ""       = x
        ifEmpty _ nonEmpty = nonEmpty
        acceptableInVariable c = isAlpha c || isDigit c
    

    Found in Data.Aeson.AutoType.CodeGen.ElmFormat from the package json-autotype
    normalizeFieldName ::  Text -> Text -> Text
    normalizeFieldName identifier = escapeKeywords             .
                                    uncapitalize               .
                                    (normalizeTypeName identifier `Text.append`) .
                                    normalizeTypeName
    
    keywords ::  Set Text
    keywords = Set.fromList ["type", "alias", "exposing", "module", "class",
                             "where", "let", "do"]
    
    escapeKeywords ::  Text -> Text
    escapeKeywords k | k `Set.member` keywords = k `Text.append` "_"
    escapeKeywords k                           = k
    
    nonNullComponents = Set.toList . Set.filter (TNull /=)
    -- | Format the type within DeclM monad, that records
    -- the separate declarations on which this one is dependent.
    formatType :: Type -> DeclM Text
    formatType  TString                          = return "String"
    formatType  TNum                             = return "Float"
    

    Found in Data.Aeson.AutoType.Extract from the package json-autotype
    unifyTypes t           s         = typeAsSet t `unifyUnion` typeAsSet s
    
    -- | Unify sets of types (sets are union types of alternatives).
    unifyUnion :: Set Type -> Set Type -> Type
    unifyUnion u v = assertions $
                       union $ uSimple        `Set.union`
                               vSimple        `Set.union`
                               unifiedObjects `Set.union`
                               Set.singleton unifiedArray
      where
        -- We partition our types for easier unification into simple and compound
        (uSimple, uCompound) = Set.partition isSimple u
        (vSimple, vCompound) = Set.partition isSimple v
        assertions = assert (Set.null $ Set.filter (not . isArray) uArr) .
                     assert (Set.null $ Set.filter (not . isArray) vArr)
        -- then we partition compound typs into objects and arrays.
        -- Note that there should be no TUnion here, since we are inside a TUnion already.
        -- (That is reduced by @union@ smart costructor as superfluous.)
        (uObj, uArr)   = Set.partition isObject uCompound
        (vObj, vArr)   = Set.partition isObject vCompound
    

    Found in Data.Aeson.AutoType.Extract from the package json-autotype
    unifyTypes (TArray u) (TArray v) = TArray $ u `unifyTypes` v
    unifyTypes t           s         = typeAsSet t `unifyUnion` typeAsSet s
    
    -- | Unify sets of types (sets are union types of alternatives).
    unifyUnion :: Set Type -> Set Type -> Type
    unifyUnion u v = assertions $
                       union $ uSimple        `Set.union`
                               vSimple        `Set.union`
                               unifiedObjects `Set.union`
                               Set.singleton unifiedArray
      where
        -- We partition our types for easier unification into simple and compound
        (uSimple, uCompound) = Set.partition isSimple u
        (vSimple, vCompound) = Set.partition isSimple v
        assertions = assert (Set.null $ Set.filter (not . isArray) uArr) .
                     assert (Set.null $ Set.filter (not . isArray) vArr)
        -- then we partition compound typs into objects and arrays.
        -- Note that there should be no TUnion here, since we are inside a TUnion already.
        -- (That is reduced by @union@ smart costructor as superfluous.)
        (uObj, uArr)   = Set.partition isObject uCompound
    

    Found in Data.Aeson.AutoType.Split from the package json-autotype
    allLabels :: Type -> [Text]
    allLabels = flip go []
      where
        go (TLabel l) ls = l:ls
        go (TArray t) ls = go t ls
        go (TUnion u) ls = Set.foldr go ls          u
        go (TObj   o) ls = Map.foldr go ls $ unDict o
        go _other     ls = ls
    
    -- * Finding candidates for extra unifications
    -- | For a given splitted types, it returns candidates for extra
    -- unifications.
    unificationCandidates :: Map.HashMap t Type -> [[t]]
    unificationCandidates = Map.elems             .
                            Map.filter candidates .
                            Map.fromListWith (++) .
                            concatMap entry       .
                            Map.toList
      where
        -- | Candidate entry has to have at least two candidates, so that unification makes sense
    

    Found in Data.Aeson.AutoType.CodeGen.HaskellFormat from the package json-autotype
            formatObjectType (normalizeTypeName name) typ
    
    -- | Normalize type name by:
    -- 1. Treating all characters that are not acceptable in Haskell variable name as end of word.
    -- 2. Capitalizing each word, but a first (camelCase).
    -- 3. Adding underscore if first character is non-alphabetic.
    -- 4. Escaping Haskell keywords if the whole identifier is such keyword.
    -- 5. If identifier is empty, then substituting "JsonEmptyKey" for its name.
    normalizeTypeName :: Text -> Text
    normalizeTypeName = ifEmpty "JsonEmptyKey"                  .
                        escapeKeywords                          .
                        escapeFirstNonAlpha                     .
                        Text.concat                             .
                        map capitalize                          .
                        filter     (not . Text.null)            .
                        Text.split (not . acceptableInVariable)
      where
        ifEmpty x ""       = x
        ifEmpty _ nonEmpty = nonEmpty
        acceptableInVariable c = isAlpha c || isDigit c
    

    Found in Data.Aeson.AutoType.CodeGen.HaskellFormat from the package json-autotype
    escapeKeywords k                           = k
    
    -- | Format the type within DeclM monad, that records
    -- the separate declarations on which this one is dependent.
    formatType :: Type -> DeclM Text
    formatType  TString                          = return "Text"
    formatType  TNum                             = return "Double"
    formatType  TBool                            = return "Bool"
    formatType (TLabel l)                        = return $ normalizeTypeName l
    formatType (TUnion u)                        = wrap <$> case length nonNull of
                                                              0 -> return emptyTypeRepr
                                                              1 -> formatType $ head nonNull
                                                              _ -> Text.intercalate ":|:" <$> mapM formatType nonNull
      where
        nonNull       = Set.toList $ Set.filter (TNull /=) u
        wrap                                :: Text -> Text
        wrap   inner  | TNull `Set.member` u = Text.concat ["(Maybe (", inner, "))"]
                      | otherwise            =                          inner
    formatType (TArray a)                        = do inner <- formatType a
                                                      return $ Text.concat ["[", inner, "]"]
    

    Found in Data.Aeson.AutoType.CodeGen.ElmFormat from the package json-autotype
            formatObjectType (normalizeTypeName name) typ
    
    -- | Normalize type name by:
    -- 1. Treating all characters that are not acceptable in Haskell variable name as end of word.
    -- 2. Capitalizing each word, but a first (camelCase).
    -- 3. Adding underscore if first character is non-alphabetic.
    -- 4. Escaping Haskell keywords if the whole identifier is such keyword.
    -- 5. If identifier is empty, then substituting "JsonEmptyKey" for its name.
    normalizeTypeName :: Text -> Text
    normalizeTypeName s  = ifEmpty "JsonEmptyKey"                  .
                           escapeKeywords                          .
                           escapeFirstNonAlpha                     .
                           Text.concat                             .
                           map capitalize                          .
                           filter     (not . Text.null)            .
                           Text.split (not . acceptableInVariable) $ s
      where
        ifEmpty x ""       = x
        ifEmpty _ nonEmpty = nonEmpty
        acceptableInVariable c = isAlpha c || isDigit c
    

    Found in Data.Aeson.AutoType.CodeGen.ElmFormat from the package json-autotype
    normalizeFieldName ::  Text -> Text -> Text
    normalizeFieldName identifier = escapeKeywords             .
                                    uncapitalize               .
                                    (normalizeTypeName identifier `Text.append`) .
                                    normalizeTypeName
    
    keywords ::  Set Text
    keywords = Set.fromList ["type", "alias", "exposing", "module", "class",
                             "where", "let", "do"]
    
    escapeKeywords ::  Text -> Text
    escapeKeywords k | k `Set.member` keywords = k `Text.append` "_"
    escapeKeywords k                           = k
    
    nonNullComponents = Set.toList . Set.filter (TNull /=)
    -- | Format the type within DeclM monad, that records
    -- the separate declarations on which this one is dependent.
    formatType :: Type -> DeclM Text
    formatType  TString                          = return "String"
    formatType  TNum                             = return "Float"
    

    Found in Data.JSON.Schema.Validate from the package json-schema
      ( S.Tuple   {}, _          ) -> err $ Mismatch sch val
      ( S.Object  {}, _          ) -> err $ Mismatch sch val
      ( S.Map     {}, _          ) -> err $ Mismatch sch val
      ( S.Value   {}, _          ) -> err $ Mismatch sch val
      ( S.Array   {}, _          ) -> err $ Mismatch sch val
    
    validateField :: S.Field -> A.Object -> M ()
    validateField f o = maybe req (nestPath (S.key f) . validate' (S.content f)) $ H.lookup (S.key f) o
      where
        req | not (S.required f) = ok
            | otherwise          = err $ MissingRequiredField (S.key f)
    
    unique :: Vector Value -> M ()
    unique vs = do
      let dups = H.filter (>= 2) . V.foldl' (\h v -> H.insertWith (+) v 1 h) H.empty $ vs
      unless (H.null dups) $
        err (NonUniqueArray dups)
    
    inLower :: S.Bound -> Scientific -> M ()
    inLower b v =
    

    Found in Math.MFSolve from the package mfsolve
      in (v, c2,
          LinExpr (-c/c2) $
          map (fmap (negate.(/c2))) r)
          
    -- | Return True if the variable is known or dependend.
    varDefined :: (Eq v, Hashable v) => v -> Dependencies v n -> Bool
    varDefined v (Dependencies _ dep _ _ _) =
      case M.lookup v dep of
        Nothing -> False
        _ -> True
    
    -- | Return all dependend variables with their dependencies.
    dependendVars :: (Eq n) => Dependencies v n -> [(v, LinExpr v n)]
    dependendVars (Dependencies _ lin _ _ _) =
      filter (notConst.snd) (M.toList lin)
      where
        notConst (LinExpr _ []) = False
        notConst _ = True
      
    

    Found in Math.MFSolve from the package mfsolve
                           simpleSubst v lt)
                 lin depVars
          -- add dependency link from independend variables to the
          -- substituted equations and (optionally) v, and remove v (since
          -- it has become dependend, so no variable can depend on it).
          depVars2 | insertp = H.insert v depVars
                   | otherwise = depVars
          -- exclude dependend variable v if k has been canceled
          tryUnion k m1 m2 =
            let xs = H.intersection m1 m2
                hasvar v2 = case M.lookup v2 lin' of
                  Nothing -> False
                  Just (LinExpr _ vs) ->
                    any ((==k).fst) vs
            in H.filter hasvar xs
               `H.union` H.difference m1 xs
               `H.union` H.difference m2 xs
          vdep' = H.foldl'
                  (\mp k -> M.insertWith (tryUnion k) k depVars2 mp)
                  (M.delete v vdep)
    

    Found in Math.MFSolve from the package mfsolve
    nonlinExpr :: Num n => [NonLinExpr v n] -> Expr v n
    nonlinExpr = Expr zeroTerm []
    
    isConst :: LinExpr v n -> Bool
    isConst (LConst _) = True
    isConst _ = False
    
    linVars :: LinExpr v n -> [v]
    linVars (LinExpr _ v) = map fst v
    
    addLin :: (Ord v, Num n, Eq n) => LinExpr v n -> LinExpr v n -> LinExpr v n
    addLin (LinExpr c1 terms1) (LinExpr c2 terms2) =
      LinExpr (c1+c2) terms3 where
        terms3 = filter ((/= 0) . snd) $
                 merge terms1 terms2 (+)
    
    addExpr :: (Ord n, Ord v, Floating n) => Expr v n -> Expr v n -> Expr v n
    addExpr (Expr lt1 trig1 nl1) (Expr lt2 trig2 nl2) =
      Expr (addLin lt1 lt2) trig3 (nl1++nl2)
    

    Found in Text.MMark.Parser from the package mmark
          | ch == ' '  = (j + 1, n + 1)
          | ch == '\t' = (j + 4, n + 1)
          | otherwise  = (j, n)
        i = unPos indent - 1
    
    assembleParagraph :: [Text] -> Text
    assembleParagraph = go
      where
        go []     = ""
        go [x]    = T.dropWhileEnd isSpace x
        go (x:xs) = x <> "\n" <> go xs
    
    collapseWhiteSpace :: Text -> Text
    collapseWhiteSpace =
      T.stripEnd . T.filter (/= '\0') . snd . T.mapAccumL f True
      where
        f seenSpace ch =
          case (seenSpace, g ch) of
            (False, False) -> (False, ch)
            (True,  False) -> (False, ch)
    

    Found in Text.MMark.Parser from the package mmark
        pipe = char '|' <* sc'
        calign = do
          let colon' = option False (True <$ char ':')
          l <- colon'
          void (count 3 (char '-') <* many (char '-'))
          r <- colon'
          sc'
          return $
            case (l, r) of
              (False, False) -> CellAlignDefault
              (True,  False) -> CellAlignLeft
              (False, True)  -> CellAlignRight
              (True,  True)  -> CellAlignCenter
        isHeaderLike txt =
          T.length (T.filter isHeaderConstituent txt) % T.length txt >
          8 % 10
        isHeaderConstituent x =
          isSpace x || x == '|' || x == '-' || x == ':'
        endOfTable =
          lookAhead (option True (isBlank <$> nonEmptyLine))
    

    Found in Text.MMark.Parser from the package mmark
            , Just <$> pTable
            , Just <$> pUnorderedList
            , Just <$> pOrderedList
            , Just <$> pBlockquote
            , pReferenceDef
            , Just <$> pParagraph ]
          _  ->
              Just <$> pIndentedCodeBlock
    
    -- | Parse a thematic break.
    
    pThematicBreak :: BParser (Block Isp)
    pThematicBreak = do
      l' <- lookAhead nonEmptyLine
      let l = T.filter (not . isSpace) l'
      if T.length l >= 3   &&
         (T.all (== '*') l ||
          T.all (== '-') l ||
          T.all (== '_') l)
        then ThematicBreak <$ nonEmptyLine <* sc
    

    Found in Text.MMark.Parser.Internal from the package mmark
         -- ^ A collection of suggested reference names in 'Left' (typo
         -- corrections) or the requested definition in 'Right'
    lookupGeneric l name = do
      let dlabel = mkDefLabel name
      defs <- gets (view (istDefs . l))
      case HM.lookup dlabel defs of
        Nothing -> return . Left $ closeNames dlabel (HM.keys defs)
        Just  x -> return (Right x)
    
    -- | Select close enough (using the normalized Damerau-Levenshtein metric)
    -- definition labels.
    
    closeNames :: DefLabel -> [DefLabel] -> [Text]
    closeNames r'
      = filter (\x -> damerauLevenshteinNorm r x >= (2 % 3))
      . map unDefLabel
      where
        r = unDefLabel r'
    
    ----------------------------------------------------------------------------
    

    Found in RIO.HashMap from the package rio
        -- * Difference and intersection
      , Data.HashMap.Strict.difference
      , Data.HashMap.Strict.differenceWith
      , Data.HashMap.Strict.intersection
      , Data.HashMap.Strict.intersectionWith
      , Data.HashMap.Strict.intersectionWithKey
    
        -- * Folds
      , Data.HashMap.Strict.foldl'
      , Data.HashMap.Strict.foldlWithKey'
      , Data.HashMap.Strict.foldr
      , Data.HashMap.Strict.foldrWithKey
    
        -- * Filter
      , Data.HashMap.Strict.filter
      , Data.HashMap.Strict.filterWithKey
      , Data.HashMap.Strict.mapMaybe
      , Data.HashMap.Strict.mapMaybeWithKey
    
        -- * Conversions
    

    Found in RIO.Prelude.Reexports from the package rio
      , Data.Functor.Identity.Identity(..)
      , Data.Hashable.Hashable
      , Data.HashMap.Strict.HashMap
      , Data.HashSet.HashSet
      , Data.Int.Int
      , Data.Int.Int8
      , Data.Int.Int16
      , Data.Int.Int32
      , Data.Int.Int64
      , Data.IntMap.Strict.IntMap
      , Data.IntSet.IntSet
      , Data.List.break
      , Data.List.drop
      , Data.List.dropWhile
      , Data.List.filter
      , Data.List.lines
      , Data.List.lookup
      , Data.List.map
      , Data.List.replicate
      , Data.List.reverse
    

    filterWithKey See 7 Occurences [+] Collapse [-]
    Found in Crypto.JWT from the package jose
    unregisteredClaims :: Lens' ClaimsSet (M.HashMap T.Text Value)
    unregisteredClaims f h@(ClaimsSet { _unregisteredClaims = a}) =
      fmap (\a' -> h { _unregisteredClaims = a' }) (f a)
    
    
    -- | Return an empty claims set.
    --
    emptyClaimsSet :: ClaimsSet
    emptyClaimsSet = ClaimsSet n n n n n n n M.empty where n = Nothing
    
    addClaim :: T.Text -> Value -> ClaimsSet -> ClaimsSet
    addClaim k v = over unregisteredClaims (M.insert k v)
    
    filterUnregistered :: M.HashMap T.Text Value -> M.HashMap T.Text Value
    filterUnregistered = M.filterWithKey (\k _ -> k `notElem` registered) where
      registered = ["iss", "sub", "aud", "exp", "nbf", "iat", "jti"]
    
    instance FromJSON ClaimsSet where
      parseJSON = withObject "JWT Claims Set" (\o -> ClaimsSet
        <$> o .:? "iss"
    

    Found in Data.HashMap.Monoidal from the package monoidal-containers
    -- | /O(n)/. Map a function to each key of a map, if it will result
    -- in duplicated mappings, their values will be merged in unspecified order
    mapKeys :: (Monoid a, Hashable k, Eq k, Hashable k', Eq k')
            => (k -> k') -> MonoidalHashMap k a -> MonoidalHashMap k' a
    mapKeys f = fromList
              . fmap (\(k, v) -> (f k, v))
              . toList
    {-# INLINE mapKeys #-}
    
    -- | /O(n)/ Filter this map by retaining only elements satisfying a
    -- predicate.
    filterWithKey :: (k -> v -> Bool) -> MonoidalHashMap k v -> MonoidalHashMap k v
    filterWithKey pred = pack . M.filterWithKey pred . unpack
    {-# INLINE filterWithKey #-}
    
    -- | /O(n)/ Transform this map by applying a function to every value.
    map :: (v1 -> v2) -> MonoidalHashMap k v1 -> MonoidalHashMap k v2
    map f = pack . M.map f . unpack
    {-# INLINE map #-}
    

    Found in Data.HashMap.Monoidal from the package monoidal-containers
    {-# INLINE modifyDef #-}
    
    -- | /O(n)/. Map a function to each key of a map, if it will result
    -- in duplicated mappings, their values will be merged in unspecified order
    mapKeys :: (Monoid a, Hashable k, Eq k, Hashable k', Eq k')
            => (k -> k') -> MonoidalHashMap k a -> MonoidalHashMap k' a
    mapKeys f = fromList
              . fmap (\(k, v) -> (f k, v))
              . toList
    {-# INLINE mapKeys #-}
    
    -- | /O(n)/ Filter this map by retaining only elements satisfying a
    -- predicate.
    filterWithKey :: (k -> v -> Bool) -> MonoidalHashMap k v -> MonoidalHashMap k v
    filterWithKey pred = pack . M.filterWithKey pred . unpack
    {-# INLINE filterWithKey #-}
    
    -- | /O(n)/ Transform this map by applying a function to every value.
    map :: (v1 -> v2) -> MonoidalHashMap k v1 -> MonoidalHashMap k v2
    map f = pack . M.map f . unpack
    

    Found in Data.HashMap.Monoidal from the package monoidal-containers
    {-# INLINE modifyDef #-}
    
    -- | /O(n)/. Map a function to each key of a map, if it will result
    -- in duplicated mappings, their values will be merged in unspecified order
    mapKeys :: (Monoid a, Hashable k, Eq k, Hashable k', Eq k')
            => (k -> k') -> MonoidalHashMap k a -> MonoidalHashMap k' a
    mapKeys f = fromList
              . fmap (\(k, v) -> (f k, v))
              . toList
    {-# INLINE mapKeys #-}
    
    -- | /O(n)/ Filter this map by retaining only elements satisfying a
    -- predicate.
    filterWithKey :: (k -> v -> Bool) -> MonoidalHashMap k v -> MonoidalHashMap k v
    filterWithKey pred = pack . M.filterWithKey pred . unpack
    {-# INLINE filterWithKey #-}
    
    -- | /O(n)/ Transform this map by applying a function to every value.
    map :: (v1 -> v2) -> MonoidalHashMap k v1 -> MonoidalHashMap k v2
    map f = pack . M.map f . unpack
    

    Found in Data.HashMap.Monoidal from the package monoidal-containers
                    . unpack
    {-# INLINE modifyDef #-}
    
    -- | /O(n)/. Map a function to each key of a map, if it will result
    -- in duplicated mappings, their values will be merged in unspecified order
    mapKeys :: (Monoid a, Hashable k, Eq k, Hashable k', Eq k')
            => (k -> k') -> MonoidalHashMap k a -> MonoidalHashMap k' a
    mapKeys f = fromList
              . fmap (\(k, v) -> (f k, v))
              . toList
    {-# INLINE mapKeys #-}
    
    -- | /O(n)/ Filter this map by retaining only elements satisfying a
    -- predicate.
    filterWithKey :: (k -> v -> Bool) -> MonoidalHashMap k v -> MonoidalHashMap k v
    filterWithKey pred = pack . M.filterWithKey pred . unpack
    {-# INLINE filterWithKey #-}
    
    -- | /O(n)/ Transform this map by applying a function to every value.
    map :: (v1 -> v2) -> MonoidalHashMap k v1 -> MonoidalHashMap k v2
    

    Found in Data.HashMap.Monoidal from the package monoidal-containers
        , fromList
        , singleton
        , size
        , member
        , notMember
        , lookup
        , lookupM
        , elems
        , keys
        , delete
        , mapKeys
        , modify
        , modifyDef
        , map
        , filterWithKey
        ) where
    
    import Prelude hiding (lookup, map)
    import Data.Maybe (fromMaybe)
    import Data.Semigroup
    

    Found in RIO.HashMap from the package rio
      , Data.HashMap.Strict.difference
      , Data.HashMap.Strict.differenceWith
      , Data.HashMap.Strict.intersection
      , Data.HashMap.Strict.intersectionWith
      , Data.HashMap.Strict.intersectionWithKey
    
        -- * Folds
      , Data.HashMap.Strict.foldl'
      , Data.HashMap.Strict.foldlWithKey'
      , Data.HashMap.Strict.foldr
      , Data.HashMap.Strict.foldrWithKey
    
        -- * Filter
      , Data.HashMap.Strict.filter
      , Data.HashMap.Strict.filterWithKey
      , Data.HashMap.Strict.mapMaybe
      , Data.HashMap.Strict.mapMaybeWithKey
    
        -- * Conversions
      , Data.HashMap.Strict.keys
    

    foldl' See 6 Occurences [+] Collapse [-]
    Found in Network.Http.Internal from the package http-common
    --
    -- | Given a list of field-name,field-value pairs, construct a Headers map.
    --
    {-
        This is only going to be used by RequestBuilder and ResponseParser,
        obviously. And yes, as usual, we go to a lot of trouble to splice out the
        function doing the work, in the name of type sanity.
    -}
    buildHeaders :: [(ByteString, ByteString)] -> Headers
    buildHeaders hs =
        Wrap result
      where
        result = foldl' addHeader empty hs
    
    {-
        insertWith is used here for the case where a header is repeated
        (for example, Set-Cookie) and the values need to be intercalated
        with ',' as per RFC 2616 §4.2.
    

    Found in Network.Http.Internal from the package http-common
                                                          copyByteString,
                                                          fromByteString,
                                                          fromByteString,
                                                          toByteString)
    import qualified Blaze.ByteString.Builder.Char8 as Builder (fromChar,
                                                                fromShow,
                                                                fromString)
    import Control.Exception (Exception)
    import Data.ByteString (ByteString)
    import qualified Data.ByteString.Char8 as S
    import Data.CaseInsensitive (CI, mk, original)
    import Data.HashMap.Strict (HashMap, delete, empty, foldrWithKey, insert,
                                insertWith, lookup, toList)
    import Data.Int (Int64)
    import Data.List (foldl')
    import Data.Monoid (mconcat, mempty)
    import Data.Typeable (Typeable)
    import Data.Word (Word16)
    
    {-
    

    Found in Math.MFSolve from the package mfsolve
      Right $ Dependencies d lin trig trig2 (e:nonlin)
    
    deleteDep :: (Hashable k, Hashable b, Eq k, Eq b) =>
                 M.HashMap b (H.HashSet k)
              -> M.HashMap k (LinExpr b n) -> k
              -> Maybe (M.HashMap b (H.HashSet k), M.HashMap k (LinExpr b n), LinExpr b n)
    deleteDep vdep lin v =
      case M.lookup v lin of
       Nothing -> Nothing
       Just lt -> Just (vdep', lin', lt)
         where
           -- delete equation of v
           lin' = M.delete v lin
           -- delete v from dependencies
           vdep' = H.foldl'
                   (flip $ M.adjust $ H.delete v)
                   vdep (H.fromList $ linVars lt)
    
    -- | Eliminate an variable from the equations.  Returns the eliminated
    -- equations.  Before elimination it performs substitution to minimize
    

    Found in Math.MFSolve from the package mfsolve
          -- substituted equations and (optionally) v, and remove v (since
          -- it has become dependend, so no variable can depend on it).
          depVars2 | insertp = H.insert v depVars
                   | otherwise = depVars
          -- exclude dependend variable v if k has been canceled
          tryUnion k m1 m2 =
            let xs = H.intersection m1 m2
                hasvar v2 = case M.lookup v2 lin' of
                  Nothing -> False
                  Just (LinExpr _ vs) ->
                    any ((==k).fst) vs
            in H.filter hasvar xs
               `H.union` H.difference m1 xs
               `H.union` H.difference m2 xs
          vdep' = H.foldl'
                  (\mp k -> M.insertWith (tryUnion k) k depVars2 mp)
                  (M.delete v vdep)
                  (H.fromList $ linVars lt)
      in (vdep', lin')
    

    Found in Math.MFSolve from the package mfsolve
    -- substitute v for lt in all linear equations
    -- if insertp is true, then add v = tl to equations
    substDep :: (Hashable v, Ord v, Num n, Eq n) =>
                 M.HashMap v (H.HashSet v) -> M.HashMap v (LinExpr v n)
                 -> v -> LinExpr v n -> Bool 
                 -> (M.HashMap v (H.HashSet v), LinearMap v n)
    substDep vdep lin v lt insertp =
           -- variables that depend on v
      let depVars = fromMaybe H.empty (M.lookup v vdep)
          -- substitute v in all dependend variables and (optionally) add
          -- v as dependend variable
          lin' = (if insertp then M.insert v lt
                  else id) $
                 H.foldl' (flip $ M.adjust $
                           substVarLin $
                           simpleSubst v lt)
                 lin depVars
          -- add dependency link from independend variables to the
          -- substituted equations and (optionally) v, and remove v (since
    

    Found in RIO.HashMap from the package rio
        -- * Transformations
      , Data.HashMap.Strict.map
      , Data.HashMap.Strict.mapWithKey
      , Data.HashMap.Strict.traverseWithKey
    
        -- * Difference and intersection
      , Data.HashMap.Strict.difference
      , Data.HashMap.Strict.differenceWith
      , Data.HashMap.Strict.intersection
      , Data.HashMap.Strict.intersectionWith
      , Data.HashMap.Strict.intersectionWithKey
    
        -- * Folds
      , Data.HashMap.Strict.foldl'
      , Data.HashMap.Strict.foldlWithKey'
      , Data.HashMap.Strict.foldr
      , Data.HashMap.Strict.foldrWithKey
    
        -- * Filter
    

    foldlWithKey' See 10 Occurences [+] Collapse [-]
    Found in Country.Unexposed.Names from the package country
       in hm3
    {-# NOINLINE decodeMap #-}
    
    -- This is only needed to support the reflex-platform fork of text. Fortunately,
    -- in all the places this is needed, it is only called to build CAFs.
    slowToTitle :: Text -> Text
    slowToTitle = T.intercalate (T.singleton ' ') . map upperFirst . T.splitOn (T.singleton ' ')
    
    upperFirst :: Text -> Text
    upperFirst t = case T.uncons t of
      Nothing -> T.empty
      Just (c,cs) -> T.cons (toUpper c) cs
    
    decodeMapUtf8 :: HashMap ByteString Country
    decodeMapUtf8 = HM.foldlWithKey' (\hm k v -> HM.insert (encodeUtf8 k) v hm) HM.empty decodeMap
    {-# NOINLINE decodeMapUtf8 #-}
    
    -- | A country recognized by ISO 3166.
    newtype Country = Country Word16
      deriving (Eq,Ord,Prim,Hashable,Storable,NFData,Generic)
    

    Found in Country.Unexposed.Names from the package country
    unnamed = T.pack "Invalid Country"
    {-# NOINLINE unnamed #-}
    
    numberOfPossibleCodes :: Int
    numberOfPossibleCodes = 1000
    
    word16ToInt :: Word16 -> Int
    word16ToInt = fromIntegral
    
    decodeMap :: HashMap Text Country
    decodeMap = 
      let baseMap = HM.union alphaTwoHashMap alphaThreeHashMap
          hm1 = L.foldl' (\hm (countryNum,name) -> HM.insert name (Country countryNum) hm) baseMap aliases
          hm2 = L.foldl' (\hm (countryNum,name,_,_) -> HM.insert name (Country countryNum) hm) hm1 countryNameQuads
          hm3 = HM.foldlWithKey' (\hm name cty -> HM.insert (T.toLower name) cty $ HM.insert (slowToTitle name) cty $ hm) hm2 hm2
       in hm3
    {-# NOINLINE decodeMap #-}
    
    -- This is only needed to support the reflex-platform fork of text. Fortunately,
    -- in all the places this is needed, it is only called to build CAFs.
    

    Found in System.Metrics.Json from the package ekg-json
    -- >       "val": 10
    -- >     },
    -- >     "baz": {
    -- >       "type": "l",
    -- >       "val": "label"
    -- >     }
    -- >   }
    -- > }
    --
    sampleToJson :: Metrics.Sample -> A.Value
    sampleToJson metrics =
        buildOne metrics $ A.emptyObject
      where
        buildOne :: M.HashMap T.Text Metrics.Value -> A.Value -> A.Value
        buildOne m o = M.foldlWithKey' build o m
    
        build :: A.Value -> T.Text -> Metrics.Value -> A.Value
        build m name val = go m (T.splitOn "." name) val
    
        go :: A.Value -> [T.Text] -> Metrics.Value -> A.Value
    

    Found in Lucid.Base from the package lucid
                            <> foldlMapWithKey buildAttr attr <> s "/>",
                     ()))
    
    -- | Build and encode an attribute.
    buildAttr :: Text -> Text -> Builder
    buildAttr key val =
      s " " <>
      Blaze.fromText key <>
      if val == mempty
         then mempty
         else s "=\"" <> Blaze.fromHtmlEscapedText val <> s "\""
    
    -- | Folding and monoidally appending attributes.
    foldlMapWithKey :: Monoid m => (k -> v -> m) -> HashMap k v -> m
    foldlMapWithKey f = M.foldlWithKey' (\m k v -> m `mappend` f k v) mempty
    
    -- | Convenience function for constructing builders.
    s :: String -> Builder
    s = Blaze.fromString
    {-# INLINE s #-}
    

    Found in PostgreSQL.Binary.Encoding.Builders from the package postgresql-binary
    hStoreRow :: Text -> Maybe Text -> Builder
    hStoreRow key value =
      sized (text_strict key) <> sizedMaybe text_strict value
    
    {-# INLINE hStore_hashMap #-}
    hStore_hashMap :: HashMap Text (Maybe Text) -> Builder
    hStore_hashMap input =
      int4_int (F.size input) <>
      F.foldlWithKey' (\payload key value -> payload <> hStoreRow key value) mempty input
    
    {-# INLINE hStore_map #-}
    hStore_map :: Map Text (Maybe Text) -> Builder
    hStore_map input =
      int4_int (Q.size input) <>
      Q.foldlWithKey' (\payload key value -> payload <> hStoreRow key value) mempty input
    

    Found in PostgreSQL.Binary.Encoding.Builders from the package postgresql-binary
    {-# INLINE hStoreFromFoldMapAndSize #-}
    hStoreFromFoldMapAndSize :: (forall a. Monoid a => (Text -> Maybe Text -> a) -> a) -> Int -> Builder
    hStoreFromFoldMapAndSize foldMap size =
      int4_int size <> foldMap hStoreRow
    
    {-# INLINE hStoreRow #-}
    hStoreRow :: Text -> Maybe Text -> Builder
    hStoreRow key value =
      sized (text_strict key) <> sizedMaybe text_strict value
    
    {-# INLINE hStore_hashMap #-}
    hStore_hashMap :: HashMap Text (Maybe Text) -> Builder
    hStore_hashMap input =
      int4_int (F.size input) <>
      F.foldlWithKey' (\payload key value -> payload <> hStoreRow key value) mempty input
    
    {-# INLINE hStore_map #-}
    hStore_map :: Map Text (Maybe Text) -> Builder
    hStore_map input =
      int4_int (Q.size input) <>
    

    Found in Rest.StringMap.HashMap.Lazy from the package rest-stringmap
    fromHashMap :: HashMap a b -> StringHashMap a b
    fromHashMap = StringHashMap
    
    toHashMap :: StringHashMap a b -> HashMap a b
    toHashMap = unH
    
    fromList :: (Eq a, Hashable a) => [(a, b)] -> StringHashMap a b
    fromList = StringHashMap . H.fromList
    
    toList :: StringHashMap a b -> [(a, b)]
    toList = H.toList . unH
    
    -- | This is used with the assumption that a = b => f a = f b
    mapKeys ::  (Hashable l, Eq l) => (k -> l) -> StringHashMap k v -> StringHashMap l v
    mapKeys f = StringHashMap . H.foldlWithKey' (\h k v -> H.insert (f k) v h) H.empty . unH
    
    -- | Base case since XmlPickler expects strings
    instance XmlPickler b => XmlPickler (StringHashMap String b) where
      xpickle = pickleStringMap fromList toList
    

    Found in Rest.StringMap.HashMap.Strict from the package rest-stringmap
    fromHashMap :: HashMap a b -> StringHashMap a b
    fromHashMap = StringHashMap
    
    toHashMap :: StringHashMap a b -> HashMap a b
    toHashMap = unH
    
    fromList :: (Eq a, Hashable a) => [(a, b)] -> StringHashMap a b
    fromList = StringHashMap . H.fromList
    
    toList :: StringHashMap a b -> [(a, b)]
    toList = H.toList . unH
    
    -- | This is used with the assumption that a = b => f a = f b
    mapKeys :: (Hashable l, Eq l) => (k -> l) -> StringHashMap k v -> StringHashMap l v
    mapKeys f = StringHashMap . H.foldlWithKey' (\h k v -> H.insert (f k) v h) H.empty . unH
    
    -- | Base case since XmlPickler expects strings
    instance XmlPickler b => XmlPickler (StringHashMap String b) where
      xpickle = pickleStringMap fromList toList
    

    Found in RIO.HashMap from the package rio
        -- * Transformations
      , Data.HashMap.Strict.map
      , Data.HashMap.Strict.mapWithKey
      , Data.HashMap.Strict.traverseWithKey
    
        -- * Difference and intersection
      , Data.HashMap.Strict.difference
      , Data.HashMap.Strict.differenceWith
      , Data.HashMap.Strict.intersection
      , Data.HashMap.Strict.intersectionWith
      , Data.HashMap.Strict.intersectionWithKey
    
        -- * Folds
      , Data.HashMap.Strict.foldl'
      , Data.HashMap.Strict.foldlWithKey'
      , Data.HashMap.Strict.foldr
      , Data.HashMap.Strict.foldrWithKey
    
        -- * Filter
      , Data.HashMap.Strict.filter
    

    Found in Graphics.Svg.Core from the package svg-builder
        go attrs =
             s2b "<" <> BB.fromText name
          <> foldlMapWithKey buildAttr attrs <> s2b ">"
    
    -- | Make an SVG element with no end tag, contains only attributes.
    makeElementNoEnd :: Text -> Element
    makeElementNoEnd name = Element $ \a -> go a
      where
        go attrs =
             s2b "<" <> BB.fromText name
          <> foldlMapWithKey buildAttr attrs <> s2b "/>"
    
    -- | Folding and monoidally appending attributes.
    foldlMapWithKey :: Monoid m => (k -> v -> m) -> HashMap k v -> m
    foldlMapWithKey f = M.foldlWithKey' (\m k v -> m `mappend` f k v) mempty
    
    s2b :: String -> Builder
    s2b = BB.fromString
    
    -- | Build and encode an attribute.
    

    foldr See 108 Occurences [+] Collapse [-]
    Found in Database.Beam.Migrate.Actions from the package beam-migrate
                      steps' = filter (not . (`HS.member` visited) . dbStateKey . measuredDbState . snd) $
                               withStrategy (parList rseq) $
                               map (\step -> let dbState' = applyStep step mdbState
                                             in dbState' `seq` (step, dbState')) steps
    
                      applyStep step (MeasuredDatabaseState score _ dbState') =
                        let dbState'' = dbStateAfterAction dbState' step
                        in measureDb (score + 1) dbState''
    
                  in case steps' of
                       -- Since no steps were generated, this is a dead end. Add to the rejected queue
                       [] -> heuristicSolver' q' visited (reject mdbState bestRejected)
                       _ -> ChooseActions dbState fst steps' $ \chosenSteps ->
                                let q'' = foldr (\(_, dbState') -> PQ.insert dbState') q' chosenSteps
                                    visited' = HS.insert (dbStateKey dbState) visited
                                in withStrategy (rparWith rseq) q'' `seq` heuristicSolver' q'' visited' bestRejected
    
        reject :: MeasuredDatabaseState cmd -> PQ.MinQueue (MeasuredDatabaseState cmd)
               -> PQ.MinQueue (MeasuredDatabaseState cmd)
    

    Found in Database.Beam.Migrate.Actions from the package beam-migrate
                                    mempty
    
        findPredicate :: forall predicate. Typeable predicate
                       => SomeDatabasePredicate
                       -> [ predicate ] -> [ predicate ]
        findPredicate
          | Just (Refl :: predicate :~: SomeDatabasePredicate) <- eqT =
              (:)
          | otherwise =
              \(SomeDatabasePredicate pred') ps ->
                  maybe ps (:ps) (cast pred')
    
        findPredicates :: forall predicate f. (Typeable predicate, Foldable f)
                       => f SomeDatabasePredicate -> [ predicate ]
        findPredicates = foldr findPredicate []
    
        heuristicSolver' !q !visited !bestRejected =
          case PQ.minView q of
            Nothing -> SearchFailed (measuredDbState <$> PQ.toList bestRejected)
            Just (mdbState@(MeasuredDatabaseState _ _ dbState), q')
    

    Found in Data.FuzzySet from the package fuzzyset
              index = fs ^._items ^? ix size ^._Just & Vector.length
           in over _matchDict (\dict  unionWith () dict dict')
            $ over (_items.at size) (Just  (`Vector.snoc` item)
                                           fromMaybe Vector.empty) fs
    
    -- | Add a list of entries to the set, in one go. 
    --
    -- > addMany = foldr (flip add)
    addMany  FuzzySet
            -- ^ Fuzzy string set to add the entries to
             [Text]
            -- ^ A list of new entries
             FuzzySet
            -- ^ A new fuzzy string set
    addMany = foldr (flip add)
    
    -- | Create a fuzzy string set with entries from the given list.
    --
    -- @fromList = addMany defaultSet@
    fromList  [Text]  FuzzySet
    

    Found in Data.FuzzySet from the package fuzzyset
    -- | Add an entry to the set and return a pair with the new set, and a boolean
    --   to indicate if a new entry was inserted, or not.
    addToSet  FuzzySet
             -- ^ Fuzzy string set to add the entry to
              Text
             -- ^ The new entry
              (FuzzySet, Bool)
             -- ^ The updated set and a boolean, which will be 'True' if, and only 
             --   if, the value was not already in the set 
    addToSet FuzzySet{..} val
        | key  exactSet = (FuzzySet{..}, False)
        | otherwise =
          let sizes = [gramSizeLower .. gramSizeUpper]
           in (foldr ξ FuzzySet{..} sizes &_exactSet %~ insert key val, True)
      where
        key = Text.toLower val
        ξ size fs =
          let dict' = flip (:) []  GramInfo index <$> gramMap (normalized val) size
              item  = FuzzySetItem (gramMap key size & elems & norm) key
    

    Found in Data.FuzzySet.Internal from the package fuzzyset
    --
    -- >>> gramMap "xxxx" 2
    -- fromList [("-x",1), ("xx",3), ("x-",1)]
    --
    -- >>> Data.HashMap.Strict.lookup "nts" (gramMap "intrent'srestaurantsomeoftrent'saunt'santswantsamtorentsomepants" 3)
    -- Just 8
    gramMap  Text
            -- ^ An input string
             Size
            -- ^ The gram size /n/, which must be at least /2/
             HashMap Text Int
            -- ^ A mapping from /n/-gram keys to the number of occurrences of the
            --   key in the list returned by 'grams' (i.e., the list of all
            --   /n/-length substrings of the input enclosed in hyphens).
    gramMap val size = foldr ζ ε (grams val size)
      where
        ζ = alter (pure  succ  fromMaybe 0)
    
    -- | Break apart the normalized input string into a list of /n/-grams. For
    --   instance, the string "Destroido Corp." is first normalized into the
    

    Found in Data.FuzzySet.Internal from the package fuzzyset
                    else rs
    
    results  GetContext  Size  [(Double, Text)]
    results GetContext{..} size = ζ <$> HashMap.toList (matches set grams)
      where
        grams  = gramMap key size
        normal = norm (elems grams)
        ζ (index, score) =
          let FuzzySetItem{..} = Vector.unsafeIndex (set ^._items.ix size) index
           in (fromIntegral score / (normal × vectorMagnitude), normalizedEntry)
    
    matches  FuzzySet  HashMap Text Int  HashMap Int Int
    matches set = foldrWithKey ζ empty
      where
        ζ gram occ m = foldr (\GramInfo{..} 
            alter (pure  (+) (occ × gramCount)  fromMaybe 0) itemIndex)
              m (set ^._matchDict.ix gram)
    
    -- | Normalize the input string, call 'grams' on the normalized input, and then
    --   translate the result to a 'HashMap' with the /n/-grams as keys and 'Int'
    

    Found in Text.Glabrous from the package glabrous
    --
    -- >λ>unsetContext context
    -- >Just (Context {variables = fromList [("name","")]})
    --
    unsetContext :: Context -> Maybe Context
    unsetContext Context {..} = do
      let vs = H.filter (== T.empty) variables
      guard (vs /= H.empty)
      return Context { variables = vs }
    
    -- | 'True' if the all variables of
    -- the given 'Context' are not empty.
    isSet :: Context -> Bool
    isSet Context{..} =
      H.foldr (\v b -> b && v /= T.empty) True variables
    
    -- | Get the list of the given 'Context' variables.
    variablesOf :: Context -> [T.Text]
    variablesOf Context{..} = H.keys variables
    

    Found in Text.Glabrous from the package glabrous
      Template { content = go content [] }
      where
        go ts !ac = do
          let (a,b) = span isLiteral ts
              u = uncons b
          if not (null a)
            then case u of
              Just (c,d) -> go d (ac ++ [concatLiterals a] ++ [c])
              Nothing    -> ac ++ [concatLiterals a]
            else case u of
              Just (e,f) -> go f (ac ++ [e])
              Nothing    -> ac
          where
            concatLiterals =
              foldr trans (Literal "")
              where
                trans (Literal a) (Literal b) = Literal (a `T.append` b)
                trans _           _           = undefined
    
    -- | Build an empty 'Context'.
    

    Found in Data.Greskell.Graph from the package greskell
    removePropertyGeneric :: Text -> PropertyMapGeneric t p v -> PropertyMapGeneric t p v
    removePropertyGeneric k (PropertyMapGeneric hm) = PropertyMapGeneric $ HM.delete k hm
    
    allPropertiesGeneric :: Foldable t => PropertyMapGeneric t p v -> [p v]
    allPropertiesGeneric (PropertyMapGeneric hm) = concat $ map toList $ HM.elems hm
    
    parsePropertiesGeneric :: (Property p, PropertyMap m, Monoid (m p v), GraphSONTyped (p v), FromGraphSON (p v), FromGraphSONWithKey (p v))
                           => (GValue -> Parser (Vector GValue))
                           -> GValue
                           -> Parser (m p v)
    parsePropertiesGeneric normalizeCardinality gv = case gValueBody gv of
      GObject obj -> foldlM folder mempty $ HM.toList obj
      _ -> empty
      where
        folder pm (k, value) = fmap (foldr putProperty pm) $ traverse (parseProperty k) =<< normalizeCardinality value
        parseProperty k value = parseTypedGValue value <|> parseGraphSONWithKey k value
    
    -- parhaps we might as well place it in GraphSON module and let it export.
    parseTypedGValue :: (GraphSONTyped v, FromGraphSON v) => GValue -> Parser v
    parseTypedGValue  gv = do
    

    Found in Data.Greskell.Graph from the package greskell
    instance Semigroup (t (p v)) => Semigroup (PropertyMapGeneric t p v) where
      (PropertyMapGeneric a) <> (PropertyMapGeneric b) = PropertyMapGeneric $ HM.unionWith (<>) a b
    
    instance Semigroup (t (p v)) => Monoid (PropertyMapGeneric t p v) where
      mempty = PropertyMapGeneric mempty
      mappend = (<>)
    
    instance (Functor t, Functor p) => Functor (PropertyMapGeneric t p) where
      fmap f (PropertyMapGeneric hm) = PropertyMapGeneric $ (fmap . fmap . fmap) f hm
    
    instance (Foldable t, Foldable p) => Foldable (PropertyMapGeneric t p) where
      foldr f start (PropertyMapGeneric hm) = foldr f2 start hm
        where
          f2 t start2 = foldr f3 start2 t
          f3 p start3 = foldr f start3 p
    
    instance (Traversable t, Traversable p) => Traversable (PropertyMapGeneric t p) where
      traverse f (PropertyMapGeneric hm) = fmap PropertyMapGeneric $ (traverse . traverse . traverse) f hm
    
    putPropertyGeneric :: (Semigroup (t (p v)), Applicative t, Property p) => p v -> PropertyMapGeneric t p v -> PropertyMapGeneric t p v
    

    Found in Data.Greskell.Graph from the package greskell
    instance Semigroup (t (p v)) => Semigroup (PropertyMapGeneric t p v) where
      (PropertyMapGeneric a) <> (PropertyMapGeneric b) = PropertyMapGeneric $ HM.unionWith (<>) a b
    
    instance Semigroup (t (p v)) => Monoid (PropertyMapGeneric t p v) where
      mempty = PropertyMapGeneric mempty
      mappend = (<>)
    
    instance (Functor t, Functor p) => Functor (PropertyMapGeneric t p) where
      fmap f (PropertyMapGeneric hm) = PropertyMapGeneric $ (fmap . fmap . fmap) f hm
    
    instance (Foldable t, Foldable p) => Foldable (PropertyMapGeneric t p) where
      foldr f start (PropertyMapGeneric hm) = foldr f2 start hm
        where
          f2 t start2 = foldr f3 start2 t
          f3 p start3 = foldr f start3 p
    
    instance (Traversable t, Traversable p) => Traversable (PropertyMapGeneric t p) where
      traverse f (PropertyMapGeneric hm) = fmap PropertyMapGeneric $ (traverse . traverse . traverse) f hm
    

    Found in Data.Greskell.Graph from the package greskell
    newtype PropertyMapGeneric t p v = PropertyMapGeneric (HM.HashMap Text (t (p v)))
                                     deriving (Show,Eq)
    
    instance Semigroup (t (p v)) => Semigroup (PropertyMapGeneric t p v) where
      (PropertyMapGeneric a) <> (PropertyMapGeneric b) = PropertyMapGeneric $ HM.unionWith (<>) a b
    
    instance Semigroup (t (p v)) => Monoid (PropertyMapGeneric t p v) where
      mempty = PropertyMapGeneric mempty
      mappend = (<>)
    
    instance (Functor t, Functor p) => Functor (PropertyMapGeneric t p) where
      fmap f (PropertyMapGeneric hm) = PropertyMapGeneric $ (fmap . fmap . fmap) f hm
    
    instance (Foldable t, Foldable p) => Foldable (PropertyMapGeneric t p) where
      foldr f start (PropertyMapGeneric hm) = foldr f2 start hm
        where
          f2 t start2 = foldr f3 start2 t
          f3 p start3 = foldr f start3 p
    
    instance (Traversable t, Traversable p) => Traversable (PropertyMapGeneric t p) where
    

    Found in Data.Greskell.Graph from the package greskell
    newtype PropertyMapGeneric t p v = PropertyMapGeneric (HM.HashMap Text (t (p v)))
                                     deriving (Show,Eq)
    
    instance Semigroup (t (p v)) => Semigroup (PropertyMapGeneric t p v) where
      (PropertyMapGeneric a) <> (PropertyMapGeneric b) = PropertyMapGeneric $ HM.unionWith (<>) a b
    
    instance Semigroup (t (p v)) => Monoid (PropertyMapGeneric t p v) where
      mempty = PropertyMapGeneric mempty
      mappend = (<>)
    
    instance (Functor t, Functor p) => Functor (PropertyMapGeneric t p) where
      fmap f (PropertyMapGeneric hm) = PropertyMapGeneric $ (fmap . fmap . fmap) f hm
    
    instance (Foldable t, Foldable p) => Foldable (PropertyMapGeneric t p) where
      foldr f start (PropertyMapGeneric hm) = foldr f2 start hm
        where
          f2 t start2 = foldr f3 start2 t
          f3 p start3 = foldr f start3 p
    
    instance (Traversable t, Traversable p) => Traversable (PropertyMapGeneric t p) where
    

    Found in Data.Greskell.Graph from the package greskell
    -- no property with the given key.
    --
    -- In version 0.1.1.0 and before, this function took an argument @m p (GraphSON Value)@.
    -- This has changed, because property types for 'AVertex' etc have changed.
    parseNonEmptyValues :: (PropertyMap m, Property p, FromGraphSON v) => Text -> m p GValue -> Parser (NonEmpty v)
    parseNonEmptyValues k pm = toNonEmpty =<< parseListValues k pm
      where
        toNonEmpty [] = fail $ notExistErrorMsg k
        toNonEmpty (x : rest) = return (x :| rest)
    
    -- | Create a 'PropertyMap' from list of 'Property's.
    fromProperties :: (PropertyMap m, Property p, Monoid (m p v))
                   => [p v]
                   -> m p v
    fromProperties = foldr putProperty mempty
    
    -- | Generic implementation of 'PropertyMap'. @t@ is the type of
    -- cardinality, @p@ is the type of 'Property' class and @v@ is the
    -- type of the property value.
    newtype PropertyMapGeneric t p v = PropertyMapGeneric (HM.HashMap Text (t (p v)))
    

    Found in Data.Greskell.Graph from the package greskell
      gsonTypeFor _ = "g:VertexProperty"
    
    instance Element (AVertexProperty v) where
      type ElementID (AVertexProperty v) = GValue
      type ElementProperty (AVertexProperty v) = AProperty
    
    instance Property AVertexProperty where
      propertyKey = avpLabel
      propertyValue = avpValue
    
    instance Functor AVertexProperty where
      fmap f vp = vp { avpValue = f $ avpValue vp }
    
    instance Foldable AVertexProperty where
      foldr f start vp = f (avpValue vp) start
    
    instance Traversable AVertexProperty where
      traverse f vp = fmap (\v -> vp { avpValue = v }) $ f $ avpValue vp
    

    Found in Data.Greskell.Graph from the package greskell
    instance FromGraphSON v => FromGraphSONWithKey (AProperty v) where
      parseGraphSONWithKey k v = AProperty k <$> parseGraphSON v
    
    instance Property AProperty where
      propertyKey = apKey
      propertyValue = apValue
    
    instance GraphSONTyped (AProperty v) where
      gsonTypeFor _ = "g:Property"
    
    instance Functor AProperty where
      fmap f sp = sp { apValue = f $ apValue sp }
    
    instance Foldable AProperty where
      foldr f start sp = f (apValue sp) start
    
    instance Traversable AProperty where
      traverse f sp = fmap (\v -> sp { apValue = v } ) $ f $ apValue sp
    
    -- | General vertex property type you can use for VertexProperty,
    

    Found in Data.Greskell.Graph from the package greskell
             PropertyMapList,
             lookupOneValue,
             lookupListValues,
             parseOneValue,
             parseListValues,
             parseNonEmptyValues,
             fromProperties,
             -- * Internal use
             FromGraphSONWithKey
           ) where
    
    import Control.Applicative (empty, (<$>), (<*>), (<|>))
    import Data.Aeson (Value(..), FromJSON(..))
    import Data.Aeson.Types (Parser)
    import Data.Foldable (toList, Foldable(foldr), foldlM)
    import qualified Data.HashMap.Strict as HM
    import Data.List.NonEmpty (NonEmpty(..))
    import qualified Data.List.NonEmpty as NL
    import Data.Maybe (listToMaybe)
    import Data.Monoid (Monoid)
    

    Found in Data.Greskell.GraphSON from the package greskell-core
             parseUnwrapList,
             (.:),
             parseJSONViaGValue
           ) where
    
    import Control.Applicative ((<$>), (<*>), (<|>))
    import Control.Monad (when)
    import Data.Aeson
      ( ToJSON(toJSON), FromJSON(parseJSON), FromJSONKey,
        object, (.=), Value(..)
      )
    import qualified Data.Aeson as Aeson
    import Data.Aeson.Types (Parser)
    import qualified Data.Aeson.Types as Aeson (parseEither)
    import Data.Foldable (Foldable(foldr))
    import Data.HashMap.Strict (HashMap)
    import qualified Data.HashMap.Strict as HM
    import qualified Data.HashMap.Lazy as L (HashMap)
    import Data.HashSet (HashSet)
    import Data.Hashable (Hashable(..))
    

    Found in Language.Javascript.JMacro.Base from the package jmacro
               JVar i -> ret JVar `app` f i
               JList xs -> ret JList `app` mapM' f xs
               JDouble _ -> ret v'
               JInt    _ -> ret v'
               JStr    _ -> ret v'
               JRegEx  _ -> ret v'
               JHash   m -> ret JHash `app` m'
                   where (ls, vs) = unzip (M.toList m)
                         m' = ret (M.fromAscList . zip ls) `app` mapM' f vs
               JFunc xs s -> ret JFunc `app` mapM' f xs `app` f s
               UnsatVal _ -> ret v'
    
      where
        mapM' :: forall a. (a -> m a) -> [a] -> m [a]
        mapM' g = foldr (app . app (ret (:)) . g) (ret [])
        f :: forall b. JMacro b => b -> m b
        f x = ret jfromGADT `app` f' (jtoGADT x)
    
    {--------------------------------------------------------------------
      New Identifiers
    

    Found in Language.Javascript.JMacro.Base from the package jmacro
               JVar i -> ret JVar `app` f i
               JList xs -> ret JList `app` mapM' f xs
               JDouble _ -> ret v'
               JInt    _ -> ret v'
               JStr    _ -> ret v'
               JRegEx  _ -> ret v'
               JHash   m -> ret JHash `app` m'
                   where (ls, vs) = unzip (M.toList m)
                         m' = ret (M.fromAscList . zip ls) `app` mapM' f vs
               JFunc xs s -> ret JFunc `app` mapM' f xs `app` f s
               UnsatVal _ -> ret v'
    
      where
        mapM' :: forall a. (a -> m a) -> [a] -> m [a]
        mapM' g = foldr (app . app (ret (:)) . g) (ret [])
        f :: forall b. JMacro b => b -> m b
        f x = ret jfromGADT `app` f' (jtoGADT x)
    
    {--------------------------------------------------------------------
      New Identifiers
    

    Found in Crypto.JWT from the package jose
    -- | A JSON string value, with the additional requirement that while
    --   arbitrary string values MAY be used, any value containing a @:@
    --   character MUST be a URI.
    --
    -- __Note__: the 'IsString' instance will fail if the string
    -- contains a @:@ but does not parse as a 'URI'.  Use 'stringOrUri'
    -- directly in this situation.
    --
    data StringOrURI = Arbitrary String | OrURI URI deriving (Eq, Show)
    
    instance Data.String.IsString StringOrURI where
      fromString = fromJust . preview stringOrUri
    
    consString :: (Cons s s Char Char, Monoid s) => Iso' s String
    consString = iso (unfoldr uncons) (foldr cons mempty)
    
    stringOrUri :: (Cons s s Char Char, Monoid s) => Prism' s StringOrURI
    stringOrUri = consString . prism' rev fwd
      where
      rev (Arbitrary s) = s
    

    Found in Crypto.JOSE.Types.Internal from the package jose
      fromChar = id
    
    instance IsChar Word8 where
      fromChar = fromIntegral . ord
    
    -- | Add appropriate base64 '=' padding.
    --
    pad :: (Snoc s s a a, IsChar a) => s -> s
    pad = rpad 4 (fromChar '=')
    {-# INLINE [2] pad #-}
    
    rpad :: (Snoc s s a a) => Int -> a -> s -> s
    rpad w a s =
      let n = ((w - snocLength s `mod` w) `mod` w)
      in foldr (.) id (replicate n (`snoc` a)) s
    {-# INLINE rpad #-}
    
    snocLength :: (Snoc s s a a) => s -> Int
    snocLength s = case unsnoc s of
      Nothing -> 0
    

    Found in Data.Aeson.AutoType.CodeGen.ElmFormat from the package json-autotype
        ifEmpty x ""       = x
        ifEmpty _ nonEmpty = nonEmpty
        acceptableInVariable c = isAlpha c || isDigit c
        escapeFirstNonAlpha cs                  | Text.null cs =                   cs
        escapeFirstNonAlpha cs@(Text.head -> c) | isAlpha   c  =                   cs
        escapeFirstNonAlpha cs                                 = "_" `Text.append` cs
    
    -- | Computes all type labels referenced by a given type.
    allLabels :: Type -> [Text]
    allLabels = flip go []
      where
        go (TLabel l) ls = l:ls
        go (TArray t) ls = go t ls
        go (TUnion u) ls = Set.foldr go ls          u
        go (TObj   o) ls = Map.foldr go ls $ unDict o
        go _other     ls = ls
    
    -- | Remaps type labels according to a `Map`.
    remapLabels :: Map Text Text -> Type -> Type
    remapLabels ls (TObj   o) = TObj   $ Dict $ Map.map (remapLabels ls) $ unDict o
    

    Found in Data.Aeson.AutoType.CodeGen.ElmFormat from the package json-autotype
      where
        ifEmpty x ""       = x
        ifEmpty _ nonEmpty = nonEmpty
        acceptableInVariable c = isAlpha c || isDigit c
        escapeFirstNonAlpha cs                  | Text.null cs =                   cs
        escapeFirstNonAlpha cs@(Text.head -> c) | isAlpha   c  =                   cs
        escapeFirstNonAlpha cs                                 = "_" `Text.append` cs
    
    -- | Computes all type labels referenced by a given type.
    allLabels :: Type -> [Text]
    allLabels = flip go []
      where
        go (TLabel l) ls = l:ls
        go (TArray t) ls = go t ls
        go (TUnion u) ls = Set.foldr go ls          u
        go (TObj   o) ls = Map.foldr go ls $ unDict o
        go _other     ls = ls
    
    -- | Remaps type labels according to a `Map`.
    remapLabels :: Map Text Text -> Type -> Type
    

    Found in Data.Aeson.AutoType.CodeGen.HaskellFormat from the package json-autotype
        ifEmpty x ""       = x
        ifEmpty _ nonEmpty = nonEmpty
        acceptableInVariable c = isAlpha c || isDigit c
        escapeFirstNonAlpha cs                  | Text.null cs =                   cs
        escapeFirstNonAlpha cs@(Text.head -> c) | isAlpha   c  =                   cs
        escapeFirstNonAlpha cs                                 = "_" `Text.append` cs
    
    -- | Computes all type labels referenced by a given type.
    allLabels :: Type -> [Text]
    allLabels = flip go []
      where
        go (TLabel l) ls = l:ls
        go (TArray t) ls = go t ls
        go (TUnion u) ls = Set.foldr go ls          u
        go (TObj   o) ls = Map.foldr go ls $ unDict o
        go _other     ls = ls
    

    Found in Data.Aeson.AutoType.CodeGen.HaskellFormat from the package json-autotype
      where
        ifEmpty x ""       = x
        ifEmpty _ nonEmpty = nonEmpty
        acceptableInVariable c = isAlpha c || isDigit c
        escapeFirstNonAlpha cs                  | Text.null cs =                   cs
        escapeFirstNonAlpha cs@(Text.head -> c) | isAlpha   c  =                   cs
        escapeFirstNonAlpha cs                                 = "_" `Text.append` cs
    
    -- | Computes all type labels referenced by a given type.
    allLabels :: Type -> [Text]
    allLabels = flip go []
      where
        go (TLabel l) ls = l:ls
        go (TArray t) ls = go t ls
        go (TUnion u) ls = Set.foldr go ls          u
        go (TObj   o) ls = Map.foldr go ls $ unDict o
        go _other     ls = ls
    

    Found in Data.Aeson.AutoType.Split from the package json-autotype
        entry (k, TObj o)                 = [(Set.fromList $ Map.keys $ unDict o, [k])]
        entry  _                          = [] -- ignore array elements and toplevel type if it is Array
    
    -- | Unifies candidates on a give input list.
    unifyCandidates :: [[Text]] -> Map Text Type -> Map Text Type
    unifyCandidates candidates splitted = Map.map (remapLabels labelMapping) $ replacements splitted
      where
        unifiedType  :: [Text] -> Type
        unifiedType cset      = foldr1 unifyTypes         $ 
                                map (splitted Map.!) cset
        replace      :: [Text] -> Map Text Type -> Map Text Type
        replace  cset@(c:_) s = Map.insert c (unifiedType cset) (foldr Map.delete s cset)
        replace  []         _ = error "Empty candidate set in replace"
        replacements :: Map Text Type -> Map Text Type
        replacements        s = foldr replace s candidates
        labelMapping :: Map Text Text
        labelMapping          = Map.fromList $ concatMap mapEntry candidates
        mapEntry cset@(c:_)   = [(x, c) | x <- cset]
        mapEntry []           = error "Empty candidate set in mapEntry"
    

    Found in Data.Aeson.AutoType.Split from the package json-autotype
        candidates [_] = False
        candidates _   = True
        -- | Make a candidate entry for each object type, which points from its keys to its label.
        entry (k, TObj o)                 = [(Set.fromList $ Map.keys $ unDict o, [k])]
        entry  _                          = [] -- ignore array elements and toplevel type if it is Array
    
    -- | Unifies candidates on a give input list.
    unifyCandidates :: [[Text]] -> Map Text Type -> Map Text Type
    unifyCandidates candidates splitted = Map.map (remapLabels labelMapping) $ replacements splitted
      where
        unifiedType  :: [Text] -> Type
        unifiedType cset      = foldr1 unifyTypes         $ 
                                map (splitted Map.!) cset
        replace      :: [Text] -> Map Text Type -> Map Text Type
        replace  cset@(c:_) s = Map.insert c (unifiedType cset) (foldr Map.delete s cset)
        replace  []         _ = error "Empty candidate set in replace"
        replacements :: Map Text Type -> Map Text Type
        replacements        s = foldr replace s candidates
        labelMapping :: Map Text Text
        labelMapping          = Map.fromList $ concatMap mapEntry candidates
    

    Found in Data.Aeson.AutoType.Split from the package json-autotype
    -- | Topological sorting of splitted types so that it is accepted declaration order.
    toposort :: Map Text Type -> [(Text, Type)]  
    toposort splitted = map ((id &&& (splitted Map.!)) . fst3 . graphKey) $ Graph.topSort graph
      where
        (graph, graphKey) = Graph.graphFromEdges' $ map makeEntry $ Map.toList splitted
        makeEntry (k, v) = (k, k, allLabels v)
    
    -- | Computes all type labels referenced by a given type.
    allLabels :: <