Data.HashSet: exported symbols usage examples

Symbols

  • delete See 19 Occurences [+] Collapse [-]
    Found in Data.Core.Graph.PureCore from the package graph-core
    neighbors (Graph{..}) adj x = IM.findWithDefault VU.empty x adj
    
    hasEdge :: Node -> Node -> Graph -> Bool
    hasEdge x y (Graph{..}) = y `VU.elem` IM.findWithDefault VU.empty x g_adj
    
    addNode :: Node -> Graph -> Graph
    addNode x g =
        g { g_adj = IM.insertWith (\_new old -> old) x VU.empty (g_adj g) }
    
    removeNode :: Node -> Graph -> Graph
    removeNode x g =
        let rmInAdj adj localF =
                foldl (\adjList child ->
                           IM.adjust (VU.filter (/=x)) child adjList
                      ) (IM.delete x adj) $ VU.toList (localF g x)
    
            newAdj = rmInAdj (g_adj g) parents
            newRAdj = rmInAdj (g_radj g) children
        in g { g_adj = newAdj
             , g_radj = newRAdj
    

    Found in Math.MFSolve from the package mfsolve
           M.delete v m)
      -- the variable is independent in:
      -- v2 = e (== sin(p+const) + const*v + linear)
      -- rearrange, and substitute
      | Just (v2, e) <-
        find (hasVar v.snd) $ M.toList m =
          let e2 = reArrangeTrig v2 e v
              substOne (v3, c)
                | v == v3 = e2 * ConstE c
                | otherwise = makeVariable v3 * ConstE c
              doSubst (Expr (LinExpr c lt) trig _) =
                foldr ((+).substOne) 
                (ConstE c + trigExpr trig) lt
          in ([makeVariable v - e],
              M.map doSubst $ M.delete v2 m)
      -- variable not found
      | otherwise =
        ([], m)
    
    dmod :: RealFrac a => a -> a -> a
    

    Found in Math.MFSolve from the package mfsolve
      in LinearE lt2 - trigExpr trig / ConstE c2
      
    elimTrig :: (Show v, Ord v, Hashable v, Floating n, Ord n) =>
                Period v n -> M.HashMap v (Expr v n) -> v
             -> ([Expr v n], M.HashMap v (Expr v n))
    elimTrig p m v
      -- period contains the variable, remove all eqs
      | any ((==v).fst) p =
          (trig2ToExpr m, M.empty)
      -- the variable is dependend in:
      -- v = e (== sin(p+const) + linear)
      -- remove the eq
      | Just e <- M.lookup v m =
          ([makeVariable v - e],
           M.delete v m)
      -- the variable is independent in:
      -- v2 = e (== sin(p+const) + const*v + linear)
      -- rearrange, and substitute
      | Just (v2, e) <-
        find (hasVar v.snd) $ M.toList m =
    

    Found in Math.MFSolve from the package mfsolve
    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
    -- the number of eliminated equations.
    

    Found in Math.MFSolve from the package mfsolve
    -- just add any other equation to the list of nonlinear equations
    addEq0 (Dependencies d lin trig trig2 nonlin) _ e =
      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)
    

    Found in Math.MFSolve from the package mfsolve
          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')
    
    addEq0 :: (Hashable v, Hashable n, RealFrac (Phase n), Ord v, Floating n) => Dependencies v n -> Expr v n -> Expr v n -> Either (DepError v n) (Dependencies v n)
    -- adding a constant equation
    

    Found in Relude.Extra.Map from the package relude
        {-# INLINE insert #-}
        {-# INLINE insertWith #-}
        {-# INLINE delete #-}
        {-# INLINE alter #-}
    
    instance DynamicMap (IntMap v) where
        insert     = IM.insert
        insertWith = IM.insertWith
        delete     = IM.delete
        alter      = IM.alter
    
        {-# INLINE insert #-}
        {-# INLINE insertWith #-}
        {-# INLINE delete #-}
        {-# INLINE alter #-}
    
    ----------------------------------------------------------------------------
    -- ToPairs
    ----------------------------------------------------------------------------
    

    Found in Relude.Extra.Map from the package relude
    instance (Eq k, Hashable k) => DynamicMap (HashMap k v) where
        insert     = HM.insert
        insertWith = HM.insertWith
        delete     = HM.delete
        alter      = HM.alter
    
        {-# INLINE insert #-}
        {-# INLINE insertWith #-}
        {-# INLINE delete #-}
        {-# INLINE alter #-}
    
    instance DynamicMap (IntMap v) where
        insert     = IM.insert
        insertWith = IM.insertWith
        delete     = IM.delete
        alter      = IM.alter
    
        {-# INLINE insert #-}
        {-# INLINE insertWith #-}
        {-# INLINE delete #-}
    

    Found in Relude.Extra.Map from the package relude
    instance (Eq k, Hashable k) => DynamicMap (HashMap k v) where
        insert     = HM.insert
        insertWith = HM.insertWith
        delete     = HM.delete
        alter      = HM.alter
    
        {-# INLINE insert #-}
        {-# INLINE insertWith #-}
        {-# INLINE delete #-}
        {-# INLINE alter #-}
    
    instance DynamicMap (IntMap v) where
        insert     = IM.insert
        insertWith = IM.insertWith
        delete     = IM.delete
        alter      = IM.alter
    
        {-# INLINE insert #-}
        {-# INLINE insertWith #-}
        {-# INLINE delete #-}
    

    Found in Relude.Extra.Map from the package relude
        {-# INLINE insert #-}
        {-# INLINE insertWith #-}
        {-# INLINE delete #-}
        {-# INLINE alter #-}
    
    instance (Eq k, Hashable k) => DynamicMap (HashMap k v) where
        insert     = HM.insert
        insertWith = HM.insertWith
        delete     = HM.delete
        alter      = HM.alter
    
        {-# INLINE insert #-}
        {-# INLINE insertWith #-}
        {-# INLINE delete #-}
        {-# INLINE alter #-}
    
    instance DynamicMap (IntMap v) where
        insert     = IM.insert
        insertWith = IM.insertWith
    

    Found in Relude.Extra.Map from the package relude
    instance Ord k => DynamicMap (Map k v) where
        insert     = M.insert
        insertWith = M.insertWith
        delete     = M.delete
        alter      = M.alter
    
        {-# INLINE insert #-}
        {-# INLINE insertWith #-}
        {-# INLINE delete #-}
        {-# INLINE alter #-}
    
    instance (Eq k, Hashable k) => DynamicMap (HashMap k v) where
        insert     = HM.insert
        insertWith = HM.insertWith
        delete     = HM.delete
        alter      = HM.alter
    
        {-# INLINE insert #-}
        {-# INLINE insertWith #-}
        {-# INLINE delete #-}
    

    Found in Relude.Extra.Map from the package relude
    instance Ord k => DynamicMap (Map k v) where
        insert     = M.insert
        insertWith = M.insertWith
        delete     = M.delete
        alter      = M.alter
    
        {-# INLINE insert #-}
        {-# INLINE insertWith #-}
        {-# INLINE delete #-}
        {-# INLINE alter #-}
    
    instance (Eq k, Hashable k) => DynamicMap (HashMap k v) where
        insert     = HM.insert
        insertWith = HM.insertWith
        delete     = HM.delete
        alter      = HM.alter
    
        {-# INLINE insert #-}
        {-# INLINE insertWith #-}
        {-# INLINE delete #-}
    

    Found in Relude.Extra.Map from the package relude
        insertWith :: (Val t -> Val t -> Val t) -> Key t -> Val t -> t -> t
    
        -- deletions
        delete :: Key t -> t -> t
        alter :: (Maybe (Val t) -> Maybe (Val t)) -> Key t -> t -> t
    
    instance Ord k => DynamicMap (Map k v) where
        insert     = M.insert
        insertWith = M.insertWith
        delete     = M.delete
        alter      = M.alter
    
        {-# INLINE insert #-}
        {-# INLINE insertWith #-}
        {-# INLINE delete #-}
        {-# INLINE alter #-}
    
    instance (Eq k, Hashable k) => DynamicMap (HashMap k v) where
        insert     = HM.insert
        insertWith = HM.insertWith
    

    Found in Relude.Extra.Map from the package relude
    {- | Modifiable Map.
    -}
    class StaticMap t => DynamicMap t where
        -- insertions
        insert     :: Key t -> Val t -> t -> t
        insertWith :: (Val t -> Val t -> Val t) -> Key t -> Val t -> t -> t
    
        -- deletions
        delete :: Key t -> t -> t
        alter :: (Maybe (Val t) -> Maybe (Val t)) -> Key t -> t -> t
    
    instance Ord k => DynamicMap (Map k v) where
        insert     = M.insert
        insertWith = M.insertWith
        delete     = M.delete
        alter      = M.alter
    
        {-# INLINE insert #-}
        {-# INLINE insertWith #-}
        {-# INLINE delete #-}
    

    Found in Relude.Extra.Map from the package relude
    {- | Modifiable Map.
    -}
    class StaticMap t => DynamicMap t where
        -- insertions
        insert     :: Key t -> Val t -> t -> t
        insertWith :: (Val t -> Val t -> Val t) -> Key t -> Val t -> t -> t
    
        -- deletions
        delete :: Key t -> t -> t
        alter :: (Maybe (Val t) -> Maybe (Val t)) -> Key t -> t -> t
    
    instance Ord k => DynamicMap (Map k v) where
        insert     = M.insert
        insertWith = M.insertWith
        delete     = M.delete
        alter      = M.alter
    
        {-# INLINE insert #-}
        {-# INLINE insertWith #-}
        {-# INLINE delete #-}
    

    Found in Relude.Extra.Map from the package relude
    {-# INLINE lookupDefault #-}
    
    ----------------------------------------------------------------------------
    -- Dynamic Map
    ----------------------------------------------------------------------------
    
    {- | Modifiable Map.
    -}
    class StaticMap t => DynamicMap t where
        -- insertions
        insert     :: Key t -> Val t -> t -> t
        insertWith :: (Val t -> Val t -> Val t) -> Key t -> Val t -> t -> t
    
        -- deletions
        delete :: Key t -> t -> t
        alter :: (Maybe (Val t) -> Maybe (Val t)) -> Key t -> t -> t
    
    instance Ord k => DynamicMap (Map k v) where
        insert     = M.insert
        insertWith = M.insertWith
    

    Found in RIO.HashSet from the package rio
      -- * Construction
      , Data.HashSet.empty
      , Data.HashSet.singleton
    
      -- * Combine
      , Data.HashSet.union
      , Data.HashSet.unions
    
      -- * Basic interface
      , Data.HashSet.null
      , Data.HashSet.size
      , Data.HashSet.member
      , Data.HashSet.insert
      , Data.HashSet.delete
    
      -- * Transformations
      , Data.HashSet.map
    
        -- * Difference and intersection
    

    Found in Database.Selda.Caching from the package selda
    invalidate :: [TableName] -> IO ()
    invalidate tns = atomicModifyIORef' theCache $ \c -> (foldl' (flip invalidate') c tns, ())
    
    invalidate' :: TableName -> ResultCache -> ResultCache
    invalidate' tbl rc
      | maxItems rc == 0 = rc
      | otherwise        = rc
        { results = results'
        , deps    = deps'
        , items   = items rc - length ks
        }
      where
        ks = maybe S.empty id $ M.lookup tbl (deps rc)
        results' = S.foldl' (flip delete) (results rc) ks
        deps' = M.delete tbl (deps rc)
    
    -- | Set the maximum number of items allowed in the cache.
    setMaxItems :: Int -> IO ()
    setMaxItems n = atomicModifyIORef' theCache $ \_ -> (setMaxItems' n, ())
    

    Found in Database.Selda.Caching from the package selda
    --   the given table.
    invalidate :: [TableName] -> IO ()
    invalidate tns = atomicModifyIORef' theCache $ \c -> (foldl' (flip invalidate') c tns, ())
    
    invalidate' :: TableName -> ResultCache -> ResultCache
    invalidate' tbl rc
      | maxItems rc == 0 = rc
      | otherwise        = rc
        { results = results'
        , deps    = deps'
        , items   = items rc - length ks
        }
      where
        ks = maybe S.empty id $ M.lookup tbl (deps rc)
        results' = S.foldl' (flip delete) (results rc) ks
        deps' = M.delete tbl (deps rc)
    
    -- | Set the maximum number of items allowed in the cache.
    setMaxItems :: Int -> IO ()
    setMaxItems n = atomicModifyIORef' theCache $ \_ -> (setMaxItems' n, ())
    

    difference See 8 Occurences [+] Collapse [-]
    Found in Database.Beam.Migrate.Actions from the package beam-migrate
                       -- 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)
        reject mdbState q =
          let q' = PQ.insert mdbState q
          in PQ.fromAscList (PQ.take rejectedCount q')
    
        dbStateAfterAction (DatabaseState curState _ cmds) action =
          let curState' = ((curState `HM.difference` HS.toMap (actionPreConditions action))
                         `HM.union` (DatabaseStateSourceDerived <$ HS.toMap (actionPostConditions action)))
          in DatabaseState curState' (HS.fromMap (() <$ curState'))
                           (cmds <> actionCommands action)
    

    Found in Database.Beam.Migrate.Actions from the package beam-migrate
    heuristicSolver :: ActionProvider cmd        -- ^ Edge discovery function
                    -> [ SomeDatabasePredicate ] -- ^ Source database state
                    -> [ SomeDatabasePredicate ] -- ^ Destination database state
                    -> Solver cmd
    heuristicSolver provider preConditionsL postConditionsL =
    
      heuristicSolver' initQueue mempty PQ.empty
    
      where
        -- Number of failed action chains to keep
        rejectedCount = 10
    
        postConditions = HS.fromList postConditionsL
        preConditions = HS.fromList preConditionsL
        allToFalsify = preConditions `HS.difference` postConditions
        measureDb = measureDb' allToFalsify postConditions
    
        initQueue = PQ.singleton (measureDb 0 initDbState)
        initDbState = DatabaseState (DatabaseStateSourceOriginal <$ HS.toMap preConditions)
                                    preConditions
    

    Found in Database.Beam.Migrate.Actions from the package beam-migrate
    measuredDbState :: MeasuredDatabaseState cmd -> DatabaseState cmd
    measuredDbState (MeasuredDatabaseState _ _ s) = s
    
    measureDb' :: HS.HashSet SomeDatabasePredicate
               -> HS.HashSet SomeDatabasePredicate
               -> Int
               -> DatabaseState cmd
               -> MeasuredDatabaseState cmd
    measureDb' _ post cmdLength st@(DatabaseState _ repr _) =
      MeasuredDatabaseState cmdLength distToGoal st
      where
    
        distToGoal = HS.size ((repr `HS.difference` post) `HS.union`
                              (post `HS.difference` repr))
    
    -- | Represents an edge (or a path) in the database graph.
    --
    -- Given a particular starting point, the destination database is the database
    -- where each predicate in 'actionPreConditions' has been removed and each
    

    Found in Database.Beam.Migrate.Actions from the package beam-migrate
    measure (MeasuredDatabaseState cmdLength estGoalDistance _) = cmdLength + 100 * estGoalDistance
    
    measuredDbState :: MeasuredDatabaseState cmd -> DatabaseState cmd
    measuredDbState (MeasuredDatabaseState _ _ s) = s
    
    measureDb' :: HS.HashSet SomeDatabasePredicate
               -> HS.HashSet SomeDatabasePredicate
               -> Int
               -> DatabaseState cmd
               -> MeasuredDatabaseState cmd
    measureDb' _ post cmdLength st@(DatabaseState _ repr _) =
      MeasuredDatabaseState cmdLength distToGoal st
      where
    
        distToGoal = HS.size ((repr `HS.difference` post) `HS.union`
                              (post `HS.difference` repr))
    
    -- | Represents an edge (or a path) in the database graph.
    --
    -- Given a particular starting point, the destination database is the database
    

    Found in Database.Beam.Migrate.Simple from the package beam-migrate
      = VerificationSucceeded
      | VerificationFailed [SomeDatabasePredicate]
      deriving Show
    
    -- | Verify that the given, beam database matches the actual
    -- schema. On success, returns 'VerificationSucceeded', on failure,
    -- returns 'VerificationFailed' and a list of missing predicates.
    verifySchema :: ( Database be db, MonadBeam cmd be handle m )
                 => BeamMigrationBackend cmd be handle m
                 -> CheckedDatabaseSettings be db
                 -> m VerificationResult
    verifySchema BeamMigrationBackend { backendGetDbConstraints = getConstraints } db =
      do actualSchema <- HS.fromList <$> getConstraints
         let expectedSchema = HS.fromList (collectChecks db)
             missingPredicates = expectedSchema `HS.difference` actualSchema
         if HS.null missingPredicates
           then pure VerificationSucceeded
           else pure (VerificationFailed (HS.toList missingPredicates))
    
    -- | Run a sequence of commands on a database
    

    Found in Math.MFSolve from the package mfsolve
          -- 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)
                  (H.fromList $ linVars lt)
      in (vdep', lin')
    

    Found in Math.MFSolve from the package mfsolve
                 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)
                  (H.fromList $ linVars lt)
    

    Found in RIO.HashSet from the package rio
      , Data.HashSet.union
      , Data.HashSet.unions
    
      -- * Basic interface
      , Data.HashSet.null
      , Data.HashSet.size
      , Data.HashSet.member
      , Data.HashSet.insert
      , Data.HashSet.delete
    
      -- * Transformations
      , Data.HashSet.map
    
        -- * Difference and intersection
      , Data.HashSet.difference
      , Data.HashSet.intersection
    
      -- * Folds
      , Data.HashSet.foldl'
      , Data.HashSet.foldr
    

    empty See 46 Occurences [+] Collapse [-]
    Found in Database.Beam.Migrate.Actions from the package beam-migrate
    {-# INLINE heuristicSolver #-}
    -- | Conduct a breadth-first search of the database graph to find a path from
    -- the source database to the destination database, using the given
    -- 'ActionProvider' to discovere "edges" (i.e., DDL commands) between the
    -- databases.
    --
    -- See the documentation on 'Solver' for more information on how to consume the
    -- result.
    heuristicSolver :: ActionProvider cmd        -- ^ Edge discovery function
                    -> [ SomeDatabasePredicate ] -- ^ Source database state
                    -> [ SomeDatabasePredicate ] -- ^ Destination database state
                    -> Solver cmd
    heuristicSolver provider preConditionsL postConditionsL =
    
      heuristicSolver' initQueue mempty PQ.empty
    
      where
        -- Number of failed action chains to keep
        rejectedCount = 10
    

    Found in Database.Beam.Migrate.Actions from the package beam-migrate
        in withStrategy (rparWith (parList rseq)) aRes `seq`
           withStrategy (rparWith (parList rseq)) bRes `seq`
           aRes ++ bRes
    
    createTableWeight, dropTableWeight, addColumnWeight, dropColumnWeight :: Int
    createTableWeight = 500
    dropTableWeight = 100
    addColumnWeight = 1
    dropColumnWeight = 1
    
    -- | Proceeds only if no predicate matches the given pattern. See the
    -- implementation of 'dropTableActionProvider' for an example of usage.
    ensuringNot_ :: Alternative m => [ a ] -> m ()
    ensuringNot_ [] = pure ()
    ensuringNot_ _  = empty
    
    -- | Used to ensure that only one predicate matches the given pattern. See the
    -- implementation of 'createTableActionProvider' for an example of usage.
    justOne_ :: [ a ] -> [ a ]
    justOne_ [x] = [x]
    

    Found in Control.Foldl from the package foldl
    Fold pairs into a hash-map.
    -}
    hashMap :: (Eq a, Hashable a) => Fold (a, b) (HashMap.HashMap a b)
    hashMap = Fold step begin done
      where
        begin = mempty
        step m (k, v) = HashMap.insert k v m
        done = id
    {-# INLINABLE hashMap #-}
    
    -- | Fold all values into a vector
    vector :: Vector v a => Fold a (v a)
    vector = Fold step begin done
      where
        begin = VectorBuilder.Builder.empty
    
        step x a = x <> VectorBuilder.Builder.singleton a
    
        done = VectorBuilder.Vector.build
    {-# INLINABLE vector #-}
    

    Found in Control.Foldl from the package foldl
      where
        step (Pair known r) a = if List.elem a known
          then Pair known r
          else Pair (a : known) (r . (a :))
        fin (Pair _ r) = r []
    {-# INLINABLE eqNub #-}
    
    -- | Fold values into a set
    set :: Ord a => Fold a (Set.Set a)
    set = Fold (flip Set.insert) Set.empty id
    {-# INLINABLE set #-}
    
    -- | Fold values into a hash-set
    hashSet :: (Eq a, Hashable a) => Fold a (HashSet.HashSet a)
    hashSet = Fold (flip HashSet.insert) HashSet.empty id
    {-# INLINABLE hashSet #-}
    
    {-|
    Fold pairs into a map.
    -}
    

    Found in Control.Foldl from the package foldl
    {-| /O(n^2)/.  Fold values into a list with duplicates removed, while preserving
        their first occurrences
    -}
    eqNub :: Eq a => Fold a [a]
    eqNub = Fold step (Pair [] id) fin
      where
        step (Pair known r) a = if List.elem a known
          then Pair known r
          else Pair (a : known) (r . (a :))
        fin (Pair _ r) = r []
    {-# INLINABLE eqNub #-}
    
    -- | Fold values into a set
    set :: Ord a => Fold a (Set.Set a)
    set = Fold (flip Set.insert) Set.empty id
    {-# INLINABLE set #-}
    
    -- | Fold values into a hash-set
    hashSet :: (Eq a, Hashable a) => Fold a (HashSet.HashSet a)
    hashSet = Fold (flip HashSet.insert) HashSet.empty id
    

    Found in Control.Foldl from the package foldl
    -- | Fold all values into a list
    list :: Fold a [a]
    list = Fold (\x a -> x . (a:)) id ($ [])
    {-# INLINABLE list #-}
    
    -- | Fold all values into a list, in reverse order
    revList :: Fold a [a]
    revList = Fold (\x a -> a:x) [] id
    {-# INLINABLE revList #-}
    
    {-| /O(n log n)/.  Fold values into a list with duplicates removed, while
        preserving their first occurrences
    -}
    nub :: Ord a => Fold a [a]
    nub = Fold step (Pair Set.empty id) fin
      where
        step (Pair s r) a = if Set.member a s
          then Pair s r
          else Pair (Set.insert a s) (r . (a :))
        fin (Pair _ r) = r []
    

    Found in Control.Foldl from the package foldl
    {-# INLINABLE lastDef #-}
    
    {-| Return the last N elements
    
    -}
    lastN :: Int -> Fold a [a]
    lastN n = Fold step begin done
      where
        step s a = s' |> a
          where
            s' =
                if Seq.length s < n
                then s
                else Seq.drop 1 s
        begin = Seq.empty
        done  = F.toList
    {-# INLINABLE lastN #-}
    
    -- | Returns 'True' if the container is empty, 'False' otherwise
    null :: Fold a Bool
    

    Found in Data.Core.Graph.PureCore from the package graph-core
        runIdentity $ hullFoldImpl (g_adj g) (\x y -> return (f x y)) initial node
    
    hullFoldM :: Monad m => Graph -> (b -> Node -> m b) -> b -> Node -> m b
    hullFoldM g = hullFoldImpl (g_adj g)
    
    hullFoldImpl :: Monad m => AdjList -> (b -> Node -> m b) -> b -> Node -> m b
    hullFoldImpl adj f initial root =
        go IS.empty initial [root]
        where
          go _ acc [] = return acc
          go !visited !acc (x:xs) =
              if (IS.member x visited)
              then go visited acc xs
              else do newAcc <- f acc x
                      let succs = IM.findWithDefault VU.empty x adj
                      go (IS.insert x visited) newAcc (xs ++ VU.toList succs)
    

    Found in Data.Core.Graph.PureCore from the package graph-core
    rhullFold :: Graph -> (b -> Node -> b) -> b -> Node -> b
    rhullFold g f initial node =
        runIdentity $ hullFoldImpl (g_radj g) (\x y -> return (f x y)) initial node
    
    -- FIXME: benchmark against old hullFold implementation
    hullFold :: Graph -> (b -> Node -> b) -> b -> Node -> b
    hullFold g f initial node =
        runIdentity $ hullFoldImpl (g_adj g) (\x y -> return (f x y)) initial node
    
    hullFoldM :: Monad m => Graph -> (b -> Node -> m b) -> b -> Node -> m b
    hullFoldM g = hullFoldImpl (g_adj g)
    
    hullFoldImpl :: Monad m => AdjList -> (b -> Node -> m b) -> b -> Node -> m b
    hullFoldImpl adj f initial root =
        go IS.empty initial [root]
        where
          go _ acc [] = return acc
          go !visited !acc (x:xs) =
              if (IS.member x visited)
              then go visited acc xs
    

    Found in Data.Core.Graph.PureCore from the package graph-core
    hull :: Graph -> Node -> NodeSet
    hull g = hullImpl g (g_adj g)
    
    rhull :: Graph -> Node -> NodeSet
    rhull g = hullImpl g (g_radj g)
    
    hullImpl :: Graph -> AdjList -> Node -> NodeSet
    hullImpl (Graph{..}) adj root =
        runST $
           do vis <- newSTRef IS.empty
              let go x =
                   (IS.member x <$> readSTRef vis) >>=
                      (flip unless $
                         do modifySTRef' vis (IS.insert x)
                            VU.forM_ (IM.findWithDefault VU.empty x adj) go)
              go root
              readSTRef vis
    
    rhullFold :: Graph -> (b -> Node -> b) -> b -> Node -> b
    rhullFold g f initial node =
    

    Found in Data.Core.Graph.PureCore from the package graph-core
              }
    
    removeEdges :: [Edge] -> Graph -> Graph
    removeEdges edgeList g = L.foldl' (flip (\(Edge x y) -> removeEdge x y)) g edgeList
    
    hull :: Graph -> Node -> NodeSet
    hull g = hullImpl g (g_adj g)
    
    rhull :: Graph -> Node -> NodeSet
    rhull g = hullImpl g (g_radj g)
    
    hullImpl :: Graph -> AdjList -> Node -> NodeSet
    hullImpl (Graph{..}) adj root =
        runST $
           do vis <- newSTRef IS.empty
              let go x =
                   (IS.member x <$> readSTRef vis) >>=
                      (flip unless $
                         do modifySTRef' vis (IS.insert x)
                            VU.forM_ (IM.findWithDefault VU.empty x adj) go)
    

    Found in Data.Core.Graph.PureCore from the package graph-core
                           IM.adjust (VU.filter (/=x)) child adjList
                      ) (IM.delete x adj) $ VU.toList (localF g x)
    
            newAdj = rmInAdj (g_adj g) parents
            newRAdj = rmInAdj (g_radj g) children
        in g { g_adj = newAdj
             , g_radj = newRAdj
             }
    
    addEdge :: Node -> Node -> Graph -> Graph
    addEdge x y g@(Graph{..}) =
       if hasEdge x y g
           then g
           else Graph { g_adj = alterDef VU.empty (flip VU.snoc y) x g_adj
                      , g_radj = alterDef VU.empty (flip VU.snoc x) y g_radj
                      }
       where alterDef def f = IM.alter (Just . f . fromMaybe def)
    
    addEdges :: [Edge] -> Graph -> Graph
    addEdges edgeList g = L.foldl' (flip (\(Edge x y) -> addEdge x y)) g edgeList
    

    Found in Data.Core.Graph.PureCore from the package graph-core
                foldl (\adjList child ->
                           IM.adjust (VU.filter (/=x)) child adjList
                      ) (IM.delete x adj) $ VU.toList (localF g x)
    
            newAdj = rmInAdj (g_adj g) parents
            newRAdj = rmInAdj (g_radj g) children
        in g { g_adj = newAdj
             , g_radj = newRAdj
             }
    
    addEdge :: Node -> Node -> Graph -> Graph
    addEdge x y g@(Graph{..}) =
       if hasEdge x y g
           then g
           else Graph { g_adj = alterDef VU.empty (flip VU.snoc y) x g_adj
                      , g_radj = alterDef VU.empty (flip VU.snoc x) y g_radj
                      }
       where alterDef def f = IM.alter (Just . f . fromMaybe def)
    
    addEdges :: [Edge] -> Graph -> Graph
    

    Found in Data.Core.Graph.PureCore from the package graph-core
    children :: Graph -> Node -> VU.Vector Node
    children g x = neighbors g (g_adj g) x
    
    parents :: Graph -> Node -> VU.Vector Node
    parents g x = neighbors g (g_radj g) x
    
    neighbors :: Graph -> AdjList -> Node -> VU.Vector Node
    neighbors (Graph{..}) adj x = IM.findWithDefault VU.empty x adj
    
    hasEdge :: Node -> Node -> Graph -> Bool
    hasEdge x y (Graph{..}) = y `VU.elem` IM.findWithDefault VU.empty x g_adj
    
    addNode :: Node -> Graph -> Graph
    addNode x g =
        g { g_adj = IM.insertWith (\_new old -> old) x VU.empty (g_adj g) }
    
    removeNode :: Node -> Graph -> Graph
    removeNode x g =
        let rmInAdj adj localF =
                foldl (\adjList child ->
    

    Found in Data.Core.Graph.PureCore from the package graph-core
    edgeCount :: Graph -> Int
    edgeCount = F.foldl' (\old (_,adj) -> old + VU.length adj) 0
              . IM.toList . g_adj
    
    children :: Graph -> Node -> VU.Vector Node
    children g x = neighbors g (g_adj g) x
    
    parents :: Graph -> Node -> VU.Vector Node
    parents g x = neighbors g (g_radj g) x
    
    neighbors :: Graph -> AdjList -> Node -> VU.Vector Node
    neighbors (Graph{..}) adj x = IM.findWithDefault VU.empty x adj
    
    hasEdge :: Node -> Node -> Graph -> Bool
    hasEdge x y (Graph{..}) = y `VU.elem` IM.findWithDefault VU.empty x g_adj
    
    addNode :: Node -> Graph -> Graph
    addNode x g =
        g { g_adj = IM.insertWith (\_new old -> old) x VU.empty (g_adj g) }
    

    Found in Data.Core.Graph.PureCore from the package graph-core
    solitaireNodes :: Graph -> [Node]
    solitaireNodes g = IM.keys (IM.filter VU.null (IM.union (g_adj g) (g_radj g)))
    
    edgeCount :: Graph -> Int
    edgeCount = F.foldl' (\old (_,adj) -> old + VU.length adj) 0
              . IM.toList . g_adj
    
    children :: Graph -> Node -> VU.Vector Node
    children g x = neighbors g (g_adj g) x
    
    parents :: Graph -> Node -> VU.Vector Node
    parents g x = neighbors g (g_radj g) x
    
    neighbors :: Graph -> AdjList -> Node -> VU.Vector Node
    neighbors (Graph{..}) adj x = IM.findWithDefault VU.empty x adj
    
    hasEdge :: Node -> Node -> Graph -> Bool
    hasEdge x y (Graph{..}) = y `VU.elem` IM.findWithDefault VU.empty x g_adj
    
    addNode :: Node -> Graph -> Graph
    

    Found in Data.Core.Graph.PureCore from the package graph-core
    fromEdges :: [Edge] -> Graph
    fromEdges edgeList =
        Graph { g_adj = mkAdj edgeList
              , g_radj = mkAdj $ map invert edgeList
              }
        where
          mkAdj e = IM.fromList $ map (src . head &&& VU.fromList . map tgt)
                            . L.groupBy ((==) `on` src)
                            . L.sortBy (compare `on` src) $ e
    
    fromAdj :: [(Node, [Node])] -> Graph
    fromAdj l =
        let g1 = fromEdges (adjToEdges l)
            solitaires = map fst $ filter (\(_, xs) -> null xs) l
        in L.foldl' (\g n -> g { g_adj = IM.insert n VU.empty (g_adj g) }) g1 solitaires
    
    nodes :: Graph -> [Node]
    nodes g = IM.keys (IM.union (g_adj g) (g_radj g))
    
    edges :: Graph -> [Edge]
    

    Found in Data.Core.Graph.PureCore from the package graph-core
    type AdjList = NodeMap (VU.Vector Node)
    data Edge = Edge { src :: !Node, tgt :: !Node } deriving (Show, Eq, Ord)
    
    instance Hashable Edge where
        hashWithSalt s (Edge x y) = s `hashWithSalt` x `hashWithSalt` y
    
    data Graph
        = Graph
        { g_adj :: !AdjList
        , g_radj :: !AdjList
        }
    
    empty :: Graph
    empty = Graph IM.empty IM.empty
    
    invert :: Edge -> Edge
    invert (Edge x y) = Edge y x
    
    instance Show Graph where
    

    Found in Data.Core.Graph.PureCore from the package graph-core
    type AdjList = NodeMap (VU.Vector Node)
    data Edge = Edge { src :: !Node, tgt :: !Node } deriving (Show, Eq, Ord)
    
    instance Hashable Edge where
        hashWithSalt s (Edge x y) = s `hashWithSalt` x `hashWithSalt` y
    
    data Graph
        = Graph
        { g_adj :: !AdjList
        , g_radj :: !AdjList
        }
    
    empty :: Graph
    empty = Graph IM.empty IM.empty
    
    invert :: Edge -> Edge
    invert (Edge x y) = Edge y x
    
    instance Show Graph where
    

    Found in Data.Core.Graph.PureCore from the package graph-core
    type AdjList = NodeMap (VU.Vector Node)
    data Edge = Edge { src :: !Node, tgt :: !Node } deriving (Show, Eq, Ord)
    
    instance Hashable Edge where
        hashWithSalt s (Edge x y) = s `hashWithSalt` x `hashWithSalt` y
    
    data Graph
        = Graph
        { g_adj :: !AdjList
        , g_radj :: !AdjList
        }
    
    empty :: Graph
    empty = Graph IM.empty IM.empty
    
    invert :: Edge -> Edge
    invert (Edge x y) = Edge y x
    
    instance Show Graph where
    

    Found in Data.Core.Graph.PureCore from the package graph-core
    import qualified Data.Vector.Unboxed as VU
    
    type AdjList = NodeMap (VU.Vector Node)
    data Edge = Edge { src :: !Node, tgt :: !Node } deriving (Show, Eq, Ord)
    
    instance Hashable Edge where
        hashWithSalt s (Edge x y) = s `hashWithSalt` x `hashWithSalt` y
    
    data Graph
        = Graph
        { g_adj :: !AdjList
        , g_radj :: !AdjList
        }
    
    empty :: Graph
    empty = Graph IM.empty IM.empty
    
    invert :: Edge -> Edge
    invert (Edge x y) = Edge y x
    

    Found in Data.Core.Graph.PureCore from the package graph-core
    {-# LANGUAGE BangPatterns #-}
    {-# LANGUAGE CPP #-}
    {-# LANGUAGE ScopedTypeVariables #-}
    {-# LANGUAGE RankNTypes #-}
    {-# LANGUAGE TupleSections #-}
    {-# LANGUAGE RecordWildCards #-}
    module Data.Core.Graph.PureCore where
    
    import Data.Core.Graph.NodeManager hiding (nodes, isConsistent)
    
    import Control.Applicative hiding (empty)
    import Control.Arrow
    import Control.DeepSeq
    import Control.Monad
    import Control.Monad.Identity
    import Control.Monad.ST
    

    Found in Haxl.Core.Stats from the package haxl
    data ProfileData = ProfileData
      { profileAllocs :: {-# UNPACK #-} !AllocCount
         -- ^ allocations made by this label
      , profileDeps :: HashSet ProfileLabel
         -- ^ labels that this label depends on
      , profileFetches :: HashMap Text Int
         -- ^ map from datasource name => fetch count
      , profileMemoHits :: {-# UNPACK #-} !MemoHitCount
        -- ^ number of hits to memoized computation at this label
      }
      deriving Show
    
    emptyProfileData :: ProfileData
    emptyProfileData = ProfileData 0 HashSet.empty HashMap.empty 0
    
    
    -- -----------------------------------------------------------------------------
    -- Allocation accounting
    

    Found in Haxl.Core.Stats from the package haxl
    data ProfileData = ProfileData
      { profileAllocs :: {-# UNPACK #-} !AllocCount
         -- ^ allocations made by this label
      , profileDeps :: HashSet ProfileLabel
         -- ^ labels that this label depends on
      , profileFetches :: HashMap Text Int
         -- ^ map from datasource name => fetch count
      , profileMemoHits :: {-# UNPACK #-} !MemoHitCount
        -- ^ number of hits to memoized computation at this label
      }
      deriving Show
    
    emptyProfileData :: ProfileData
    emptyProfileData = ProfileData 0 HashSet.empty HashMap.empty 0
    
    
    -- -----------------------------------------------------------------------------
    -- Allocation accounting
    

    Found in Haxl.Core.Stats from the package haxl
    -- ---------------------------------------------------------------------------
    -- Profiling
    
    type ProfileLabel = Text
    type AllocCount = Int64
    type MemoHitCount = Int64
    
    newtype Profile = Profile
      { profile      :: HashMap ProfileLabel ProfileData
         -- ^ Data on individual labels.
      }
    
    emptyProfile :: Profile
    emptyProfile = Profile HashMap.empty
    
    data ProfileData = ProfileData
      { profileAllocs :: {-# UNPACK #-} !AllocCount
         -- ^ allocations made by this label
      , profileDeps :: HashSet ProfileLabel
    

    Found in Language.C.Inline.HaskellIdentifier from the package inline-c
      fromString s =
        case haskellIdentifierFromString s of
          Left err -> error $ "HaskellIdentifier fromString: invalid string " ++ s ++ ":\n" ++ err
          Right x -> x
    
    instance PP.Pretty HaskellIdentifier where
      pretty = PP.text . unHaskellIdentifier
    
    haskellIdentifierFromString :: String -> Either String HaskellIdentifier
    haskellIdentifierFromString s =
      case C.runCParser cpc "haskellIdentifierFromString" s (parseHaskellIdentifier <* eof) of
        Left err -> Left $ show err
        Right x -> Right x
      where
        cpc = haskellCParserContext HashSet.empty
    
    haskellCParserContext :: C.TypeNames -> C.CParserContext HaskellIdentifier
    haskellCParserContext typeNames = C.CParserContext
      { C.cpcTypeNames = typeNames
      , C.cpcParseIdent = parseHaskellIdentifier
    

    Found in Language.C.Types.Parse from the package inline-c
      -> a
    quickCParser typeNames s p = case runCParser typeNames "quickCParser" s p of
      Left err -> error $ "quickCParser: " ++ show err
      Right x -> x
    
    -- | Like 'quickCParser', but uses @'cCParserContext' ('const' 'False')@ as
    -- 'CParserContext'.
    quickCParser_
      :: String
      -- ^ String to parse.
      -> (ReaderT (CParserContext CIdentifier) (Parsec.Parsec String ()) a)
      -- ^ Parser.  Anything with type @forall m. CParser i m => m a@ is a
      -- valid argument.
      -> a
    quickCParser_ = quickCParser (cCParserContext HashSet.empty)
    
    cReservedWords :: HashSet.HashSet String
    cReservedWords = HashSet.fromList
      [ "auto", "else", "long", "switch"
      , "break", "enum", "register", "typedef"
    

    Found in Math.MFSolve from the package mfsolve
          LinExpr (c/negate c2) r
          `addLin` LinExpr 0 [(v2, 1/c2)])
    
    reArrangeTrig :: (Show v, Ord t1, Ord v, Floating t1) => v -> Expr v t1 -> v -> Expr v t1
    reArrangeTrig v2 (Expr lt trig _) v =
      let (c2, lt2) = reArrange v2 lt v
      in LinearE lt2 - trigExpr trig / ConstE c2
      
    elimTrig :: (Show v, Ord v, Hashable v, Floating n, Ord n) =>
                Period v n -> M.HashMap v (Expr v n) -> v
             -> ([Expr v n], M.HashMap v (Expr v n))
    elimTrig p m v
      -- period contains the variable, remove all eqs
      | any ((==v).fst) p =
          (trig2ToExpr m, M.empty)
      -- the variable is dependend in:
      -- v = e (== sin(p+const) + linear)
      -- remove the eq
      | Just e <- M.lookup v m =
          ([makeVariable v - e],
    

    Found in Math.MFSolve from the package mfsolve
                 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 $
                     map (subst $ simpleSubst v lt2)
                     (trig'++trig2'++nonlin) of
                 Left _ -> (deps, e) --shouldn't happen
                 Right d -> (d, e)
      | otherwise =
          let (l, trig2') =
                M.foldrWithKey trigFold
                ([], M.empty) trig2
              trigFold p t (l2, m2) =
                let (l3, m1) = elimTrig p t v
                    mp | M.null m1 = m2
                       | otherwise = M.insert p m1 m2
                in (l3++l2, mp)
    

    Found in Math.MFSolve from the package mfsolve
         [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 $
                     map (subst $ simpleSubst v lt2)
    

    Found in Math.MFSolve from the package mfsolve
    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)])] []) =
      if null lt then
    

    Found in Math.MFSolve from the package mfsolve
    select :: [a] -> [(a, [a])]
    select [] = []
    select (x:xs) =
      (x,xs) : [(y,x:ys) | (y,ys) <- select xs]
    
    -- 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 $
    

    Found in Math.MFSolve from the package mfsolve
    substVarTrig s (period, terms) =
      let period2 = LinearE $ substVarLin s (LinExpr 0 period)
          terms2 = map (fmap $ LinearE . substVarLin s) terms
      in foldr (\(p,a) -> (+ (a * sin (ConstE p + period2))))
         0 terms2
    
    subst :: (Ord n, Ord v, Floating n) => (v -> Maybe (LinExpr v n)) -> Expr v n -> Expr v n
    subst s (Expr lt trig nl) =
      LinearE (substVarLin s lt) +
      foldr ((+).substVarTrig s) 0 trig +
      foldr ((+).substVarNonLin s) 0 nl
    
    -- | An empty system of equations.
    noDeps :: Dependencies v n
    noDeps = Dependencies M.empty M.empty [] M.empty []
    
    simpleSubst :: Eq a => a -> b -> a -> Maybe b
    simpleSubst x y z
      | x == z = Just y
      | otherwise = Nothing
    

    Found in Math.MFSolve from the package mfsolve
    substVarTrig s (period, terms) =
      let period2 = LinearE $ substVarLin s (LinExpr 0 period)
          terms2 = map (fmap $ LinearE . substVarLin s) terms
      in foldr (\(p,a) -> (+ (a * sin (ConstE p + period2))))
         0 terms2
    
    subst :: (Ord n, Ord v, Floating n) => (v -> Maybe (LinExpr v n)) -> Expr v n -> Expr v n
    subst s (Expr lt trig nl) =
      LinearE (substVarLin s lt) +
      foldr ((+).substVarTrig s) 0 trig +
      foldr ((+).substVarNonLin s) 0 nl
    
    -- | An empty system of equations.
    noDeps :: Dependencies v n
    noDeps = Dependencies M.empty M.empty [] M.empty []
    
    simpleSubst :: Eq a => a -> b -> a -> Maybe b
    simpleSubst x y z
      | x == z = Just y
      | otherwise = Nothing
    

    Found in Math.MFSolve from the package mfsolve
    substVarTrig s (period, terms) =
      let period2 = LinearE $ substVarLin s (LinExpr 0 period)
          terms2 = map (fmap $ LinearE . substVarLin s) terms
      in foldr (\(p,a) -> (+ (a * sin (ConstE p + period2))))
         0 terms2
    
    subst :: (Ord n, Ord v, Floating n) => (v -> Maybe (LinExpr v n)) -> Expr v n -> Expr v n
    subst s (Expr lt trig nl) =
      LinearE (substVarLin s lt) +
      foldr ((+).substVarTrig s) 0 trig +
      foldr ((+).substVarNonLin s) 0 nl
    
    -- | An empty system of equations.
    noDeps :: Dependencies v n
    noDeps = Dependencies M.empty M.empty [] M.empty []
    
    simpleSubst :: Eq a => a -> b -> a -> Maybe b
    simpleSubst x y z
      | x == z = Just y
      | otherwise = Nothing
    

    Found in Text.Parser.Token from the package parsers
      local f = Unspaced . Class.local f . runUnspaced
      {-# INLINE local #-}
    
    instance MonadWriter e m => MonadWriter e (Unspaced m) where
      tell = lift . Class.tell
      {-# INLINE tell #-}
      listen = Unspaced . Class.listen . runUnspaced
      {-# INLINE listen #-}
      pass = Unspaced . Class.pass . runUnspaced
      {-# INLINE pass #-}
    
    instance TokenParsing m => TokenParsing (Unspaced m) where
      nesting (Unspaced m) = Unspaced (nesting m)
      {-# INLINE nesting #-}
      someSpace = empty
      {-# INLINE someSpace #-}
      semi      = Unspaced semi
      {-# INLINE semi #-}
      highlight h (Unspaced m) = Unspaced (highlight h m)
      {-# INLINE highlight #-}
    

    Found in Text.Parser.Token from the package parsers
          bounded' dps@(zero:_) bds = skipSome zero *> ([] <$ notFollowedBy (choice dps) <|> bounded'' dps bds)
                                  <|> bounded'' dps bds
          bounded' []           _   = error "bounded called with base 0"
          bounded'' dps []         = [] <$ notFollowedBy (choice dps) <|> toomuch
          bounded'' dps (bd : bds) = let anyd :: m Char
                                         anyd = choice dps
    
                                         nomore :: m ()
                                         nomore = notFollowedBy anyd <|> toomuch
                                         (low, ex : high) = splitAt bd dps
                                      in ((:) <$> choice low <*> atMost (length bds) anyd) <* nomore
                                         <|> ((:) <$> ex <*> ([] <$ nomore <|> bounded'' dps bds))
                                         <|> if not (null bds)
                                                then (:) <$> choice high <*> atMost (length bds - 1) anyd <* nomore
                                                else empty
          atMost n p | n <= 0    = pure []
                     | otherwise = ((:) <$> p <*> atMost (n - 1) p) <|> pure []
    
      charEsc :: m Char
      charEsc = choice $ parseEsc <$> escMap
    

    Found in Text.Parser.Token from the package parsers
    import Control.Monad.State.Class as Class
    import Control.Monad.Reader.Class as Class
    import Control.Monad.Writer.Class as Class
    import Data.Char
    import Data.Functor.Identity
    import qualified Data.HashSet as HashSet
    import Data.HashSet (HashSet)
    import Data.List (foldl', transpose)
    #if __GLASGOW_HASKELL__ < 710
    import Data.Monoid
    #endif
    import Data.Scientific ( Scientific )
    import qualified Data.Scientific as Sci
    import Data.String
    import Data.Text hiding (empty,zip,foldl',take,map,length,splitAt,null,transpose)
    import Numeric (showIntAtBase)
    import qualified Text.ParserCombinators.ReadP as ReadP
    import qualified Text.Parsec as Parsec
    import qualified Data.Attoparsec.Types as Att
    import Text.Parser.Char
    

    Found in Relude.Nub from the package relude
      where
        go _ []     = []
        go s (x:xs) =
          if x `Set.member` s
          then go s xs
          else x : go (Set.insert x s) xs
    
    {- | Like 'Prelude.nub' but runs in @O(n * log_16(n))@ time and requires 'Hashable'.
    
    >>> hashNub [3, 3, 3, 2, 2, -1, 1]
    [3,2,-1,1]
    
    -}
    hashNub :: (Eq a, Hashable a) => [a] -> [a]
    hashNub = go HashSet.empty
      where
        go _ []     = []
        go s (x:xs) =
          if x `HashSet.member` s
          then go s xs
    

    Found in Relude.Nub from the package relude
    import Data.Hashable (Hashable)
    import Data.HashSet as HashSet
    import Data.Ord (Ord)
    import Prelude ((.))
    
    import qualified Data.Set as Set
    
    {- | Like 'Prelude.nub' but runs in @O(n * log n)@ time and requires 'Ord'.
    
    >>> ordNub [3, 3, 3, 2, 2, -1, 1]
    [3,2,-1,1]
    
    -}
    ordNub :: (Ord a) => [a] -> [a]
    ordNub = go Set.empty
      where
        go _ []     = []
        go s (x:xs) =
          if x `Set.member` s
          then go s xs
    

    Found in RIO.HashSet from the package rio
    -- | @Set@ with hashed members. Import as:
    --
    -- > import qualified RIO.HashSet as HS
    module RIO.HashSet
      (
        Data.HashSet.HashSet
    
      -- * Construction
      , Data.HashSet.empty
      , Data.HashSet.singleton
    
      -- * Combine
      , Data.HashSet.union
      , Data.HashSet.unions
    

    Found in Database.Selda.Caching from the package selda
    -- | Invalidate all items in the per-process cache that depend on
    --   the given table.
    invalidate :: [TableName] -> IO ()
    invalidate tns = atomicModifyIORef' theCache $ \c -> (foldl' (flip invalidate') c tns, ())
    
    invalidate' :: TableName -> ResultCache -> ResultCache
    invalidate' tbl rc
      | maxItems rc == 0 = rc
      | otherwise        = rc
        { results = results'
        , deps    = deps'
        , items   = items rc - length ks
        }
      where
        ks = maybe S.empty id $ M.lookup tbl (deps rc)
        results' = S.foldl' (flip delete) (results rc) ks
        deps' = M.delete tbl (deps rc)
    
    -- | Set the maximum number of items allowed in the cache.
    setMaxItems :: Int -> IO ()
    

    Found in Database.Selda.Caching from the package selda
        -- | Table to query mapping, for keeping track of which queries depend on
        --   which tables.
      , deps     :: !(M.HashMap TableName (S.HashSet CacheKey))
        -- | Items currently in cache.
      , items    :: !Int
        -- | Max number of items in cache.
      , maxItems :: !Int
        -- | Next cache prio to use.
      , nextPrio :: !Int
      } deriving Show
    
    emptyCache :: ResultCache
    emptyCache = ResultCache
      { results  = empty
      , deps     = M.empty
      , items    = 0
      , maxItems = 0
      , nextPrio = 0
      }
    

    Found in Database.Selda.Caching from the package selda
        results  :: !(HashPSQ CacheKey Int Dynamic)
        -- | Table to query mapping, for keeping track of which queries depend on
        --   which tables.
      , deps     :: !(M.HashMap TableName (S.HashSet CacheKey))
        -- | Items currently in cache.
      , items    :: !Int
        -- | Max number of items in cache.
      , maxItems :: !Int
        -- | Next cache prio to use.
      , nextPrio :: !Int
      } deriving Show
    
    emptyCache :: ResultCache
    emptyCache = ResultCache
      { results  = empty
      , deps     = M.empty
      , items    = 0
      , maxItems = 0
      , nextPrio = 0
      }
    

    Found in Universum.Nub from the package universum
    ordNub :: (Ord a) => [a] -> [a]
    ordNub = go Set.empty
      where
        go _ []     = []
        go s (x:xs) =
          if x `Set.member` s
          then go s xs
          else x : go (Set.insert x s) xs
    
    -- | Like 'Prelude.nub' but runs in @O(n * log_16(n))@ time and requires 'Hashable'.
    --
    -- >>> hashNub [3, 3, 3, 2, 2, -1, 1]
    -- [3,2,-1,1]
    hashNub :: (Eq a, Hashable a) => [a] -> [a]
    hashNub = go HashSet.empty
      where
        go _ []     = []
        go s (x:xs) =
          if x `HashSet.member` s
          then go s xs
    

    Found in Universum.Nub from the package universum
        dups ([])   = {v | Set_emp v}
        dups (x:xs) = {v | v =
          if (Set_mem x (listElts xs))
          then (Set_cup (Set_sng x) (dups xs))
          else (dups xs)}
    @-}
    
    {-@ Set.toList :: Set a -> ListUnique a @-}
    
    -- | Like 'Prelude.nub' but runs in @O(n * log n)@ time and requires 'Ord'.
    --
    -- >>> ordNub [3, 3, 3, 2, 2, -1, 1]
    -- [3,2,-1,1]
    ordNub :: (Ord a) => [a] -> [a]
    ordNub = go Set.empty
      where
        go _ []     = []
        go s (x:xs) =
          if x `Set.member` s
          then go s xs
    

    filter See 6 Occurences [+] Collapse [-]
    Found in Data.Core.Graph.PureCore from the package graph-core
    addEdge x y g@(Graph{..}) =
       if hasEdge x y g
           then g
           else Graph { g_adj = alterDef VU.empty (flip VU.snoc y) x g_adj
                      , g_radj = alterDef VU.empty (flip VU.snoc x) y g_radj
                      }
       where alterDef def f = IM.alter (Just . f . fromMaybe def)
    
    addEdges :: [Edge] -> Graph -> Graph
    addEdges edgeList g = L.foldl' (flip (\(Edge x y) -> addEdge x y)) g edgeList
    
    removeEdge :: Node -> Node -> Graph -> Graph
    removeEdge x y (Graph{..}) =
        Graph { g_adj = IM.adjust (VU.filter (/=y)) x g_adj
              , g_radj = IM.adjust (VU.filter (/=x)) y g_radj
              }
    
    removeEdges :: [Edge] -> Graph -> Graph
    removeEdges edgeList g = L.foldl' (flip (\(Edge x y) -> removeEdge x y)) g edgeList
    

    Found in Data.Core.Graph.PureCore from the package graph-core
    addEdge :: Node -> Node -> Graph -> Graph
    addEdge x y g@(Graph{..}) =
       if hasEdge x y g
           then g
           else Graph { g_adj = alterDef VU.empty (flip VU.snoc y) x g_adj
                      , g_radj = alterDef VU.empty (flip VU.snoc x) y g_radj
                      }
       where alterDef def f = IM.alter (Just . f . fromMaybe def)
    
    addEdges :: [Edge] -> Graph -> Graph
    addEdges edgeList g = L.foldl' (flip (\(Edge x y) -> addEdge x y)) g edgeList
    
    removeEdge :: Node -> Node -> Graph -> Graph
    removeEdge x y (Graph{..}) =
        Graph { g_adj = IM.adjust (VU.filter (/=y)) x g_adj
              , g_radj = IM.adjust (VU.filter (/=x)) y g_radj
              }
    
    removeEdges :: [Edge] -> Graph -> Graph
    removeEdges edgeList g = L.foldl' (flip (\(Edge x y) -> removeEdge x y)) g edgeList
    

    Found in Data.Core.Graph.PureCore from the package graph-core
    neighbors :: Graph -> AdjList -> Node -> VU.Vector Node
    neighbors (Graph{..}) adj x = IM.findWithDefault VU.empty x adj
    
    hasEdge :: Node -> Node -> Graph -> Bool
    hasEdge x y (Graph{..}) = y `VU.elem` IM.findWithDefault VU.empty x g_adj
    
    addNode :: Node -> Graph -> Graph
    addNode x g =
        g { g_adj = IM.insertWith (\_new old -> old) x VU.empty (g_adj g) }
    
    removeNode :: Node -> Graph -> Graph
    removeNode x g =
        let rmInAdj adj localF =
                foldl (\adjList child ->
                           IM.adjust (VU.filter (/=x)) child adjList
                      ) (IM.delete x adj) $ VU.toList (localF g x)
    
            newAdj = rmInAdj (g_adj g) parents
            newRAdj = rmInAdj (g_radj g) children
        in g { g_adj = newAdj
    

    Found in Data.Core.Graph.PureCore from the package graph-core
    fromAdj :: [(Node, [Node])] -> Graph
    fromAdj l =
        let g1 = fromEdges (adjToEdges l)
            solitaires = map fst $ filter (\(_, xs) -> null xs) l
        in L.foldl' (\g n -> g { g_adj = IM.insert n VU.empty (g_adj g) }) g1 solitaires
    
    nodes :: Graph -> [Node]
    nodes g = IM.keys (IM.union (g_adj g) (g_radj g))
    
    edges :: Graph -> [Edge]
    edges = edgesAdj . g_adj
    
    solitaireNodes :: Graph -> [Node]
    solitaireNodes g = IM.keys (IM.filter VU.null (IM.union (g_adj g) (g_radj g)))
    
    edgeCount :: Graph -> Int
    edgeCount = F.foldl' (\old (_,adj) -> old + VU.length adj) 0
              . IM.toList . g_adj
    

    Found in Data.Core.Graph.PureCore from the package graph-core
    fromEdges :: [Edge] -> Graph
    fromEdges edgeList =
        Graph { g_adj = mkAdj edgeList
              , g_radj = mkAdj $ map invert edgeList
              }
        where
          mkAdj e = IM.fromList $ map (src . head &&& VU.fromList . map tgt)
                            . L.groupBy ((==) `on` src)
                            . L.sortBy (compare `on` src) $ e
    
    fromAdj :: [(Node, [Node])] -> Graph
    fromAdj l =
        let g1 = fromEdges (adjToEdges l)
            solitaires = map fst $ filter (\(_, xs) -> null xs) l
        in L.foldl' (\g n -> g { g_adj = IM.insert n VU.empty (g_adj g) }) g1 solitaires
    
    nodes :: Graph -> [Node]
    nodes g = IM.keys (IM.union (g_adj g) (g_radj g))
    

    Found in RIO.HashSet from the package rio
      , Data.HashSet.delete
    
      -- * Transformations
      , Data.HashSet.map
    
        -- * Difference and intersection
      , Data.HashSet.difference
      , Data.HashSet.intersection
    
      -- * Folds
      , Data.HashSet.foldl'
      , Data.HashSet.foldr
    
      -- * Filter
      , Data.HashSet.filter
    
      -- * Conversions
    
      -- ** Lists
      , Data.HashSet.toList
    

    foldl' See 1 Occurences [+] Collapse [-]
    Found in RIO.HashSet from the package rio
      , Data.HashSet.null
      , Data.HashSet.size
      , Data.HashSet.member
      , Data.HashSet.insert
      , Data.HashSet.delete
    
      -- * Transformations
      , Data.HashSet.map
    
        -- * Difference and intersection
      , Data.HashSet.difference
      , Data.HashSet.intersection
    
      -- * Folds
      , Data.HashSet.foldl'
      , Data.HashSet.foldr
    
      -- * Filter
      , Data.HashSet.filter
    

    foldr See 3 Occurences [+] Collapse [-]
    Found in Text.Parser.Token from the package parsers
        esc = Nothing <$ escapeGap
          <|> Nothing <$ escapeEmpty
          <|> Just <$> escapeCode
    
      escapeEmpty, escapeGap :: m Char
      escapeEmpty = char '&'
      escapeGap = skipSome space *> (char '\\' <?> "end of string gap")
    {-# INLINE stringLiteral #-}
    
    -- | This token parser behaves as 'stringLiteral', but for single-quoted
    -- strings.
    stringLiteral' :: forall m s. (TokenParsing m, IsString s) => m s
    stringLiteral' = fromString <$> token (highlight StringLiteral lit) where
      lit :: m [Char]
      lit = Prelude.foldr (maybe id (:)) ""
        <$> between (char '\'') (char '\'' <?> "end of string") (many stringChar)
        <?> "string"
    
      stringChar :: m (Maybe Char)
      stringChar = Just <$> stringLetter
    

    Found in Text.Parser.Token from the package parsers
    charLiteral = token (highlight CharLiteral lit) where
      lit :: m Char
      lit = between (char '\'') (char '\'' <?> "end of character") characterChar
        <?> "character"
    {-# INLINE charLiteral #-}
    
    -- | This token parser parses a literal string. Returns the literal
    -- string value. This parsers deals correctly with escape sequences and
    -- gaps. The literal string is parsed according to the grammar rules
    -- defined in the Haskell report (which matches most programming
    -- languages quite closely).
    stringLiteral :: forall m s. (TokenParsing m, IsString s) => m s
    stringLiteral = fromString <$> token (highlight StringLiteral lit) where
      lit :: m [Char]
      lit = Prelude.foldr (maybe id (:)) ""
        <$> between (char '"') (char '"' <?> "end of string") (many stringChar)
        <?> "string"
    
      stringChar :: m (Maybe Char)
      stringChar = Just <$> stringLetter
    

    Found in RIO.HashSet from the package rio
      , Data.HashSet.size
      , Data.HashSet.member
      , Data.HashSet.insert
      , Data.HashSet.delete
    
      -- * Transformations
      , Data.HashSet.map
    
        -- * Difference and intersection
      , Data.HashSet.difference
      , Data.HashSet.intersection
    
      -- * Folds
      , Data.HashSet.foldl'
      , Data.HashSet.foldr
    
      -- * Filter
      , Data.HashSet.filter
    
      -- * Conversions
    

    fromList See 57 Occurences [+] Collapse [-]
    Found in Database.Beam.Migrate.Actions from the package beam-migrate
    -- result.
    heuristicSolver :: ActionProvider cmd        -- ^ Edge discovery function
                    -> [ SomeDatabasePredicate ] -- ^ Source database state
                    -> [ SomeDatabasePredicate ] -- ^ Destination database state
                    -> Solver cmd
    heuristicSolver provider preConditionsL postConditionsL =
    
      heuristicSolver' initQueue mempty PQ.empty
    
      where
        -- Number of failed action chains to keep
        rejectedCount = 10
    
        postConditions = HS.fromList postConditionsL
        preConditions = HS.fromList preConditionsL
        allToFalsify = preConditions `HS.difference` postConditions
        measureDb = measureDb' allToFalsify postConditions
    
        initQueue = PQ.singleton (measureDb 0 initDbState)
        initDbState = DatabaseState (DatabaseStateSourceOriginal <$ HS.toMap preConditions)
    

    Found in Database.Beam.Migrate.Actions from the package beam-migrate
    -- See the documentation on 'Solver' for more information on how to consume the
    -- result.
    heuristicSolver :: ActionProvider cmd        -- ^ Edge discovery function
                    -> [ SomeDatabasePredicate ] -- ^ Source database state
                    -> [ SomeDatabasePredicate ] -- ^ Destination database state
                    -> Solver cmd
    heuristicSolver provider preConditionsL postConditionsL =
    
      heuristicSolver' initQueue mempty PQ.empty
    
      where
        -- Number of failed action chains to keep
        rejectedCount = 10
    
        postConditions = HS.fromList postConditionsL
        preConditions = HS.fromList preConditionsL
        allToFalsify = preConditions `HS.difference` postConditions
        measureDb = measureDb' allToFalsify postConditions
    
        initQueue = PQ.singleton (measureDb 0 initDbState)
    

    Found in Database.Beam.Migrate.Actions from the package beam-migrate
      where
        provider :: ActionProviderFn cmd
        provider findPreConditions _ =
          do colP@(TableColumnHasConstraint tblNm colNm _ :: TableColumnHasConstraint (Sql92DdlCommandColumnSchemaSyntax cmd))
               <- findPreConditions
    -- TODO         guard (c == notNullConstraintSyntax)
    
             TableExistsPredicate tblNm' <- findPreConditions
             guard (tblNm == tblNm')
    
             TableHasColumn tblNm'' colNm' _ :: TableHasColumn (Sql92DdlCommandColumnSchemaSyntax cmd) <- findPreConditions
             guard (tblNm == tblNm'' && colNm == colNm')
    
             let cmd = alterTableCmd (alterTableSyntax tblNm (alterColumnSyntax colNm setNullSyntax))
             pure (PotentialAction (HS.fromList [SomeDatabasePredicate colP]) mempty
                                   (Seq.singleton (MigrationCommand cmd MigrationKeepsData))
                                   ("Drop not null constraint for " <> colNm <> " on " <> tblNm) 100)
    
    -- | Default action providers for any SQL92 compliant syntax.
    --
    

    Found in Database.Beam.Migrate.Actions from the package beam-migrate
      where
        provider :: ActionProviderFn cmd
        provider findPreConditions findPostConditions =
          do colP@(TableColumnHasConstraint tblNm colNm _ :: TableColumnHasConstraint (Sql92DdlCommandColumnSchemaSyntax cmd))
               <- findPostConditions
    -- TODO         guard (c == notNullConstraintSyntax)
    
             TableExistsPredicate tblNm' <- findPreConditions
             guard (tblNm == tblNm')
    
             TableHasColumn tblNm'' colNm' _ :: TableHasColumn (Sql92DdlCommandColumnSchemaSyntax cmd) <- findPreConditions
             guard (tblNm == tblNm'' && colNm == colNm')
    
             let cmd = alterTableCmd (alterTableSyntax tblNm (alterColumnSyntax colNm setNotNullSyntax))
             pure (PotentialAction mempty (HS.fromList [SomeDatabasePredicate colP])
                                   (Seq.singleton (MigrationCommand cmd MigrationKeepsData))
                                   ("Add not null constraint to " <> colNm <> " on " <> tblNm) 100)
    
    -- | Action provider for SQL92 @ALTER TABLE ... ALTER COLUMN ... SET  NOT NULL@
    dropColumnNullProvider :: forall cmd
    

    Found in Database.Beam.Migrate.Actions from the package beam-migrate
    --         TableExistsPredicate tblNm' <- trace ("COnsider drop " <> show tblNm <> " " <> show colNm)  findPreConditions
    --         guard (any (\(TableExistsPredicate tblNm') -> tblNm' == tblNm) findPreConditions) --tblNm' == tblNm)
    --         ensuringNot_ $ do
    --           TableHasColumn tblNm' colNm' colType' :: TableHasColumn (Sql92DdlCommandColumnSchemaSyntax cmd) <-
    --             findPostConditions
    --           guard (tblNm' == tblNm && colNm == colNm' && colType == colType') -- This column exists as a different type
    
             relatedPreds <- --pure []
               pure $ do p'@(SomeDatabasePredicate pred') <- findPreConditions
                         guard (pred' `predicateCascadesDropOn` colP)
                         pure p'
    
             let cmd = alterTableCmd (alterTableSyntax tblNm (dropColumnSyntax colNm))
             pure (PotentialAction (HS.fromList (SomeDatabasePredicate colP:relatedPreds)) mempty
                                   (Seq.singleton (MigrationCommand cmd MigrationLosesData))
                                   ("Drop column " <> colNm <> " from " <> tblNm)
                    (dropColumnWeight + fromIntegral (T.length tblNm + T.length colNm)))
    
    -- | Action provider for SQL92 @ALTER TABLE ... ALTER COLUMN ... SET NULL@
    

    Found in Database.Beam.Migrate.Actions from the package beam-migrate
      where
        provider :: ActionProviderFn cmd
        provider findPreConditions findPostConditions =
          do colP@(TableHasColumn tblNm colNm colType :: TableHasColumn (Sql92DdlCommandColumnSchemaSyntax cmd))
               <- findPostConditions
             TableExistsPredicate tblNm' <- findPreConditions
             guard (tblNm' == tblNm)
             ensuringNot_ $ do
               TableHasColumn tblNm'' colNm' _ :: TableHasColumn (Sql92DdlCommandColumnSchemaSyntax cmd) <-
                 findPreConditions
               guard (tblNm'' == tblNm && colNm == colNm') -- This column exists as a different type
    
             let cmd = alterTableCmd (alterTableSyntax tblNm (addColumnSyntax colNm schema))
                 schema = columnSchemaSyntax colType Nothing [] Nothing
             pure (PotentialAction mempty (HS.fromList [SomeDatabasePredicate colP])
                                   (Seq.singleton (MigrationCommand cmd MigrationKeepsData))
                                   ("Add column " <> colNm <> " to " <> tblNm)
                    (addColumnWeight + fromIntegral (T.length tblNm + T.length colNm)))
    
    -- | Action provider for SQL92 @ALTER TABLE ... DROP COLUMN ...@ actions
    

    Found in Database.Beam.Migrate.Actions from the package beam-migrate
       provider findPreConditions findPostConditions =
         do tblP@(TableExistsPredicate preTblNm) <- findPreConditions
            ensuringNot_ $
              do TableExistsPredicate postTblNm <- findPostConditions
                 guard (preTblNm == postTblNm)
    
            relatedPreds <-
              pure $ do p'@(SomeDatabasePredicate pred') <- findPreConditions
                        guard (pred' `predicateCascadesDropOn` tblP)
                        pure p'
    
            -- Now, collect all preconditions that may be related to the dropped table
            let cmd = dropTableCmd (dropTableSyntax preTblNm)
            pure ({-trace ("Dropping table " <> show preTblNm <> " would drop " <> show relatedPreds) $ -}
                  PotentialAction (HS.fromList (SomeDatabasePredicate tblP:relatedPreds)) mempty
                                  (Seq.singleton (MigrationCommand cmd MigrationLosesData))
                                  ("Drop table " <> preTblNm) dropTableWeight)
    
    -- | Action provider for SQL92 @ALTER TABLE ... ADD COLUMN ...@ actions
    addColumnProvider :: forall cmd
    

    Found in Database.Beam.Migrate.Actions from the package beam-migrate
                    pure (p constraintP, c)
    
                  pure (p columnP:constraintsP, (colNm, schema, constraints))
             (primaryKeyP, primaryKey) <- justOne_ $ do
               primaryKeyP@(TableHasPrimaryKey tblNm primaryKey) <-
                 findPostConditions
               guard (tblNm == postTblNm)
               pure (primaryKeyP, primaryKey)
    
             let postConditions = [ p tblP, p primaryKeyP ] ++ concat columnsP
                 cmd = createTableCmd (createTableSyntax Nothing postTblNm colsSyntax tblConstraints)
                 tblConstraints = if null primaryKey then [] else [ primaryKeyConstraintSyntax primaryKey ]
                 colsSyntax = map (\(colNm, type_, cs) -> (colNm, columnSchemaSyntax type_ Nothing cs Nothing)) columns
             pure (PotentialAction mempty (HS.fromList postConditions)
                                   (Seq.singleton (MigrationCommand cmd MigrationKeepsData))
                                   ("Create the table " <> postTblNm) createTableWeight)
    
    -- | Action provider for SQL92 @DROP TABLE@ actions
    dropTableActionProvider :: forall cmd
    

    Found in Database.Beam.Migrate.Simple from the package beam-migrate
    data VerificationResult
      = VerificationSucceeded
      | VerificationFailed [SomeDatabasePredicate]
      deriving Show
    
    -- | Verify that the given, beam database matches the actual
    -- schema. On success, returns 'VerificationSucceeded', on failure,
    -- returns 'VerificationFailed' and a list of missing predicates.
    verifySchema :: ( Database be db, MonadBeam cmd be handle m )
                 => BeamMigrationBackend cmd be handle m
                 -> CheckedDatabaseSettings be db
                 -> m VerificationResult
    verifySchema BeamMigrationBackend { backendGetDbConstraints = getConstraints } db =
      do actualSchema <- HS.fromList <$> getConstraints
         let expectedSchema = HS.fromList (collectChecks db)
             missingPredicates = expectedSchema `HS.difference` actualSchema
         if HS.null missingPredicates
           then pure VerificationSucceeded
           else pure (VerificationFailed (HS.toList missingPredicates))
    

    Found in Database.Beam.Migrate.Simple from the package beam-migrate
    -- | Result type for 'verifySchema'
    data VerificationResult
      = VerificationSucceeded
      | VerificationFailed [SomeDatabasePredicate]
      deriving Show
    
    -- | Verify that the given, beam database matches the actual
    -- schema. On success, returns 'VerificationSucceeded', on failure,
    -- returns 'VerificationFailed' and a list of missing predicates.
    verifySchema :: ( Database be db, MonadBeam cmd be handle m )
                 => BeamMigrationBackend cmd be handle m
                 -> CheckedDatabaseSettings be db
                 -> m VerificationResult
    verifySchema BeamMigrationBackend { backendGetDbConstraints = getConstraints } db =
      do actualSchema <- HS.fromList <$> getConstraints
         let expectedSchema = HS.fromList (collectChecks db)
             missingPredicates = expectedSchema `HS.difference` actualSchema
         if HS.null missingPredicates
           then pure VerificationSucceeded
           else pure (VerificationFailed (HS.toList missingPredicates))
    

    Found in Data.Binary.Orphans from the package binary-orphans
      put = put . Semigroup.getFirst
    
    -- | /Since: binary-orphans-0.1.3.0/
    instance Binary a => Binary (Semigroup.Last a) where
      get = fmap Semigroup.Last get
      put = put . Semigroup.getLast
    
    -- | /Since: binary-orphans-0.1.3.0/
    instance Binary a => Binary (Semigroup.Option a) where
      get = fmap Semigroup.Option get
      put = put . Semigroup.getOption
    
    -- | /Since: binary-orphans-0.1.3.0/
    instance Binary a => Binary (NE.NonEmpty a) where
      get = fmap NE.fromList get
      put = put . NE.toList
    
    -- | /Since: binary-orphans-0.1.5.0/
    instance Binary m => Binary (Semigroup.WrappedMonoid m) where
      get = fmap Semigroup.WrapMonoid get
    

    Found in Data.Binary.Orphans from the package binary-orphans
      put (A.Object v) = put (0 :: Int) >> put v
      put (A.Array v)  = put (1 :: Int) >> put v
      put (A.String v) = put (2 :: Int) >> put v
      put (A.Number v) = put (3 :: Int) >> put v
      put (A.Bool v)   = put (4 :: Int) >> put v
      put A.Null       = put (5 :: Int)
    
    
    instance  (Hashable.Hashable k, Eq k, Binary k, Binary v) => Binary (HM.HashMap k v) where
      get = fmap HM.fromList get
      put = put . HM.toList
    
    instance (Hashable.Hashable v, Eq v, Binary v) => Binary (HS.HashSet v) where
      get = fmap HS.fromList get
      put = put . HS.toList
    
    #if MIN_VERSION_hashable(1,2,5)
    instance (Hashable.Hashable a, Binary a) => Binary (Hashable.Hashed a) where
      get = fmap Hashable.hashed get
    

    Found in Data.Binary.Orphans from the package binary-orphans
          3 -> fmap A.Number get
          4 -> fmap A.Bool get
          5 -> return A.Null
          _ -> fail $ "Invalid Value tag: " ++ show t
    
      put (A.Object v) = put (0 :: Int) >> put v
      put (A.Array v)  = put (1 :: Int) >> put v
      put (A.String v) = put (2 :: Int) >> put v
      put (A.Number v) = put (3 :: Int) >> put v
      put (A.Bool v)   = put (4 :: Int) >> put v
      put A.Null       = put (5 :: Int)
    
    
    instance  (Hashable.Hashable k, Eq k, Binary k, Binary v) => Binary (HM.HashMap k v) where
      get = fmap HM.fromList get
      put = put . HM.toList
    
    instance (Hashable.Hashable v, Eq v, Binary v) => Binary (HS.HashSet v) where
      get = fmap HS.fromList get
      put = put . HS.toList
    

    Found in Data.Bytes.Serial from the package bytes
      deserializeWith gv = IMap.fromList
                   `liftM` deserializeWith (deserializeWith2 deserialize gv)
    
    instance (Ord k, Serial k) => Serial1 (Map.Map k) where
      -- serializeWith = serializeWith2 serialize
      -- deserializeWith = deserializeWith2 deserialize
      serializeWith pv = serializeWith (serializeWith2 serialize pv)
                       . Map.toAscList
      deserializeWith gv = Map.fromList
                   `liftM` deserializeWith (deserializeWith2 deserialize gv)
    
    instance (Hashable k, Eq k, Serial k) => Serial1 (HMap.HashMap k) where
      serializeWith pv = serializeWith (serializeWith2 serialize pv)
                       . HMap.toList
      deserializeWith gv = HMap.fromList
                   `liftM` deserializeWith (deserializeWith2 deserialize gv)
    
    serialize1 :: (MonadPut m, Serial1 f, Serial a) => f a -> m ()
    serialize1 = serializeWith serialize
    {-# INLINE serialize1 #-}
    

    Found in Data.Bytes.Serial from the package bytes
      deserializeWith gv = Set.fromList `liftM` deserializeWith gv
    -}
    
    instance Serial1 IMap.IntMap where
      serializeWith pv = serializeWith (serializeWith2 serialize pv)
                       . IMap.toAscList
      deserializeWith gv = IMap.fromList
                   `liftM` deserializeWith (deserializeWith2 deserialize gv)
    
    instance (Ord k, Serial k) => Serial1 (Map.Map k) where
      -- serializeWith = serializeWith2 serialize
      -- deserializeWith = deserializeWith2 deserialize
      serializeWith pv = serializeWith (serializeWith2 serialize pv)
                       . Map.toAscList
      deserializeWith gv = Map.fromList
                   `liftM` deserializeWith (deserializeWith2 deserialize gv)
    
    instance (Hashable k, Eq k, Serial k) => Serial1 (HMap.HashMap k) where
      serializeWith pv = serializeWith (serializeWith2 serialize pv)
                       . HMap.toList
    

    Found in Data.Bytes.Serial from the package bytes
    instance Serial1 NEL.NonEmpty where
      serializeWith pv = serializeWith pv . F.toList
      deserializeWith gv = NEL.fromList `liftM` deserializeWith gv
    
    {-
    instance Serial1 Set.Set where
      serializeWith pv = serializeWith pv . Set.toAscList
      deserializeWith gv = Set.fromList `liftM` deserializeWith gv
    -}
    
    instance Serial1 IMap.IntMap where
      serializeWith pv = serializeWith (serializeWith2 serialize pv)
                       . IMap.toAscList
      deserializeWith gv = IMap.fromList
                   `liftM` deserializeWith (deserializeWith2 deserialize gv)
    
    instance (Ord k, Serial k) => Serial1 (Map.Map k) where
      -- serializeWith = serializeWith2 serialize
      -- deserializeWith = deserializeWith2 deserialize
    

    Found in Data.Bytes.Serial from the package bytes
      deserializeWith = deserializeWith2 deserialize
    instance (Serial a, Serial b, Serial c) => Serial1 ((,,,) a b c) where
      serializeWith = serializeWith2 serialize
      deserializeWith = deserializeWith2 deserialize
    instance (Serial a, Serial b, Serial c, Serial d) => Serial1 ((,,,,) a b c d) where
      serializeWith = serializeWith2 serialize
      deserializeWith = deserializeWith2 deserialize
    
    instance Serial1 Seq.Seq where
      serializeWith pv = serializeWith pv . F.toList
      deserializeWith gv = Seq.fromList `liftM` deserializeWith gv
    
    instance Serial1 NEL.NonEmpty where
      serializeWith pv = serializeWith pv . F.toList
      deserializeWith gv = NEL.fromList `liftM` deserializeWith gv
    
    {-
    instance Serial1 Set.Set where
      serializeWith pv = serializeWith pv . Set.toAscList
      deserializeWith gv = Set.fromList `liftM` deserializeWith gv
    

    Found in Data.Bytes.Serial from the package bytes
      serializeWith = serializeWith2 serialize
      deserializeWith = deserializeWith2 deserialize
    instance (Serial a, Serial b) => Serial1 ((,,) a b) where
      serializeWith = serializeWith2 serialize
      deserializeWith = deserializeWith2 deserialize
    instance (Serial a, Serial b, Serial c) => Serial1 ((,,,) a b c) where
      serializeWith = serializeWith2 serialize
      deserializeWith = deserializeWith2 deserialize
    instance (Serial a, Serial b, Serial c, Serial d) => Serial1 ((,,,,) a b c d) where
      serializeWith = serializeWith2 serialize
      deserializeWith = deserializeWith2 deserialize
    
    instance Serial1 Seq.Seq where
      serializeWith pv = serializeWith pv . F.toList
      deserializeWith gv = Seq.fromList `liftM` deserializeWith gv
    
    instance Serial1 NEL.NonEmpty where
      serializeWith pv = serializeWith pv . F.toList
      deserializeWith gv = NEL.fromList `liftM` deserializeWith gv
    

    Found in Data.Bytes.Serial from the package bytes
    instance Serial v => Serial (IMap.IntMap v) where
      serialize = serializeWith serialize
      deserialize = deserializeWith deserialize
    
    instance (Serial k, Serial v, Ord k) => Serial (Map.Map k v) where
      serialize = serializeWith serialize
      deserialize = deserializeWith deserialize
    
    instance (Serial k, Serial v, Hashable k, Eq k) => Serial (HMap.HashMap k v) where
      serialize = serializeWith serialize
      deserialize = deserializeWith deserialize
    
    instance (Serial v, Hashable v, Eq v) => Serial (HSet.HashSet v) where
      serialize = serialize . HSet.toList
      deserialize = HSet.fromList `liftM` deserialize
    
    putVarInt :: (MonadPut m, Integral a, Bits a) => a -> m ()
    putVarInt n
      | n < 0x80 = putWord8 $ fromIntegral n
      | otherwise = do
    

    Found in Data.Bytes.Serial from the package bytes
    instance Serial ISet.IntSet where
      serialize = serialize . ISet.toAscList
      deserialize = ISet.fromList `liftM` deserialize
    
    instance Serial a => Serial (Seq.Seq a) where
      serialize = serializeWith serialize
      deserialize = deserializeWith deserialize
    
    instance Serial a => Serial (NEL.NonEmpty a) where
      serialize = serializeWith serialize
      deserialize = deserializeWith deserialize
    
    instance (Serial a, Ord a) => Serial (Set.Set a) where
      serialize = serialize . Set.toAscList
      deserialize = Set.fromList `liftM` deserialize
    
    instance Serial v => Serial (IMap.IntMap v) where
      serialize = serializeWith serialize
      deserialize = deserializeWith deserialize
    

    Found in Data.Bytes.Serial from the package bytes
    instance Serial Int8 where
      serialize = putWord8 . fromIntegral
      deserialize = liftM fromIntegral getWord8
    
    instance Serial Sci.Scientific where
      serialize s = serialize (Sci.coefficient s, Sci.base10Exponent s)
      deserialize = uncurry Sci.scientific <$> deserialize
    
    instance Serial Void where
      serialize = absurd
      deserialize = fail "I looked into the void."
    
    instance Serial ISet.IntSet where
      serialize = serialize . ISet.toAscList
      deserialize = ISet.fromList `liftM` deserialize
    
    instance Serial a => Serial (Seq.Seq a) where
      serialize = serializeWith serialize
      deserialize = deserializeWith deserialize
    

    Found in Data.Core.Graph.PureCore from the package graph-core
    edgesAdj :: AdjList -> [Edge]
    edgesAdj adj = adjToEdges . map (second VU.toList) $ IM.toList adj
    
    isConsistent :: Graph -> Bool
    isConsistent (Graph{..}) = L.sort forwardEdges == L.sort (map invert (edgesAdj g_radj))
                            && HS.size (HS.fromList forwardEdges) == length forwardEdges
        where forwardEdges = edgesAdj g_adj
    
    fromEdges :: [Edge] -> Graph
    fromEdges edgeList =
        Graph { g_adj = mkAdj edgeList
              , g_radj = mkAdj $ map invert edgeList
              }
        where
          mkAdj e = IM.fromList $ map (src . head &&& VU.fromList . map tgt)
                            . L.groupBy ((==) `on` src)
                            . L.sortBy (compare `on` src) $ e
    
    fromAdj :: [(Node, [Node])] -> Graph
    fromAdj l =
    

    Found in Data.Core.Graph.PureCore from the package graph-core
    edgesAdj :: AdjList -> [Edge]
    edgesAdj adj = adjToEdges . map (second VU.toList) $ IM.toList adj
    
    isConsistent :: Graph -> Bool
    isConsistent (Graph{..}) = L.sort forwardEdges == L.sort (map invert (edgesAdj g_radj))
                            && HS.size (HS.fromList forwardEdges) == length forwardEdges
        where forwardEdges = edgesAdj g_adj
    
    fromEdges :: [Edge] -> Graph
    fromEdges edgeList =
        Graph { g_adj = mkAdj edgeList
              , g_radj = mkAdj $ map invert edgeList
              }
        where
          mkAdj e = IM.fromList $ map (src . head &&& VU.fromList . map tgt)
                            . L.groupBy ((==) `on` src)
                            . L.sortBy (compare `on` src) $ e
    
    fromAdj :: [(Node, [Node])] -> Graph
    fromAdj l =
    

    Found in Data.Core.Graph.PureCore from the package graph-core
                      (nodes a)
          where sameItems x y = IS.fromList x == IS.fromList y
    
    instance NFData Graph where
        rnf (Graph a b) = rnf a `seq` rnf b
    
    adjToEdges :: [(Node, [Node])] -> [Edge]
    adjToEdges = concatMap (\(x, ys) -> map (Edge x) ys)
    
    edgesAdj :: AdjList -> [Edge]
    edgesAdj adj = adjToEdges . map (second VU.toList) $ IM.toList adj
    
    isConsistent :: Graph -> Bool
    isConsistent (Graph{..}) = L.sort forwardEdges == L.sort (map invert (edgesAdj g_radj))
                            && HS.size (HS.fromList forwardEdges) == length forwardEdges
        where forwardEdges = edgesAdj g_adj
    
    fromEdges :: [Edge] -> Graph
    fromEdges edgeList =
        Graph { g_adj = mkAdj edgeList
    

    Found in Data.Core.Graph.PureCore from the package graph-core
    invert :: Edge -> Edge
    invert (Edge x y) = Edge y x
    
    instance Show Graph where
        show g = "< " ++ L.intercalate ",\n  " (map showNode (nodes g)) ++ " >"
            where showNode x = show x
                            ++ " -> ["
                            ++ L.intercalate "," (map show (VU.toList (children g x)))
                            ++ "]"
    
    instance Eq Graph where
        a == b = sameItems (nodes a) (nodes b)
              && all (\x -> sameItems (VU.toList (children a x)) (VU.toList (children b x)))
                      (nodes a)
          where sameItems x y = IS.fromList x == IS.fromList y
    
    instance NFData Graph where
        rnf (Graph a b) = rnf a `seq` rnf b
    
    adjToEdges :: [(Node, [Node])] -> [Edge]
    

    Found in Data.Core.Graph.PureCore from the package graph-core
    invert :: Edge -> Edge
    invert (Edge x y) = Edge y x
    
    instance Show Graph where
        show g = "< " ++ L.intercalate ",\n  " (map showNode (nodes g)) ++ " >"
            where showNode x = show x
                            ++ " -> ["
                            ++ L.intercalate "," (map show (VU.toList (children g x)))
                            ++ "]"
    
    instance Eq Graph where
        a == b = sameItems (nodes a) (nodes b)
              && all (\x -> sameItems (VU.toList (children a x)) (VU.toList (children b x)))
                      (nodes a)
          where sameItems x y = IS.fromList x == IS.fromList y
    
    instance NFData Graph where
        rnf (Graph a b) = rnf a `seq` rnf b
    
    adjToEdges :: [(Node, [Node])] -> [Edge]
    

    Found in Data.Greskell.GraphSON from the package greskell-core
    -- --
    -- -- Useful to implement 'FromGraphSON' instances for 'Traversable'
    -- -- types.
    -- parseUnwrapTraversable :: (Traversable t, FromJSON (t GValue), FromGraphSON a)
    --                        => GValue -> Parser (t a)
    -- parseUnwrapTraversable gv = traverse parseGraphSON =<< (parseJSON $ unwrapOne gv)
    
    -- | Extract 'GArray' from the given 'GValue', parse the items in the
    -- array, and gather them by 'List.fromList'.
    --
    -- Useful to implement 'FromGraphSON' instances for 'IsList' types.
    --
    -- @since 0.1.2.0
    parseUnwrapList :: (IsList a, i ~ Item a, FromGraphSON i) => GValue -> Parser a
    parseUnwrapList (GValue (GraphSON _ (GArray v))) = fmap List.fromList $ traverse parseGraphSON $ List.toList v
    parseUnwrapList (GValue (GraphSON _ body)) = fail ("Expects GArray, but got " ++ show body)
    
    -- | Parse 'GValue' into 'FromGraphSON'.
    --
    -- @since 0.1.2.0
    

    Found in Data.Greskell.GraphSON from the package greskell-core
    import Data.Monoid (mempty)
    import Data.Ratio (Ratio)
    import Data.Scientific (Scientific)
    import Data.Sequence (Seq)
    import Data.Set (Set)
    import Data.Text (Text, unpack)
    import qualified Data.Text.Lazy as TL
    import Data.Traversable (Traversable(traverse))
    import Data.UUID (UUID)
    import qualified Data.UUID as UUID
    import Data.Vector (Vector)
    import Data.Word (Word8, Word16, Word32, Word64)
    import Numeric.Natural (Natural)
    import GHC.Exts (IsList(Item))
    import qualified GHC.Exts as List (fromList, toList)
    import GHC.Generics (Generic)
    
    import Data.Greskell.GMap
      ( GMap, GMapEntry, unGMap,
        FlattenedMap, parseToFlattenedMap, parseToGMap, parseToGMapEntry
    

    Found in Language.C.Inline.Context from the package inline-c
            _ -> do
              fail "impossible: got type different from `long' (vecCtx)"
      }
    
    
    -- | 'bsCtx' serves exactly the same purpose as 'vecCtx', but only for
    -- 'BS.ByteString'.  @vec-ptr@ becomes @bs-ptr@, and @vec-len@ becomes
    -- @bs-len@.  You don't need to specify the type of the pointer in
    -- @bs-ptr@, it will always be @char*@.
    --
    -- Moreover, @bs-cstr@ works as @bs-ptr@ but it provides a null-terminated
    -- copy of the given 'BS.ByteString'.
    bsCtx :: Context
    bsCtx = mempty
      { ctxAntiQuoters = Map.fromList
          [ ("bs-ptr", SomeAntiQuoter bsPtrAntiQuoter)
          , ("bs-len", SomeAntiQuoter bsLenAntiQuoter)
          , ("bs-cstr", SomeAntiQuoter bsCStrAntiQuoter)
          ]
      }
    

    Found in Language.C.Inline.Context from the package inline-c
    -- Specifically, the @vec-len@ and @vec-ptr@ will get the length and the
    -- pointer underlying mutable ('V.IOVector') and immutable ('V.Vector')
    -- storable vectors.
    --
    -- Note that if you use 'vecCtx' to manipulate immutable vectors you
    -- must make sure that the vector is not modified in the C code.
    --
    -- To use @vec-len@, simply write @$vec-len:x@, where @x@ is something
    -- of type @'V.IOVector' a@ or @'V.Vector' a@, for some @a@.  To use
    -- @vec-ptr@ you need to specify the type of the pointer,
    -- e.g. @$vec-len:(int *x)@ will work if @x@ has type @'V.IOVector'
    -- 'CInt'@.
    vecCtx :: Context
    vecCtx = mempty
      { ctxAntiQuoters = Map.fromList
          [ ("vec-ptr", SomeAntiQuoter vecPtrAntiQuoter)
          , ("vec-len", SomeAntiQuoter vecLenAntiQuoter)
          ]
      }
    

    Found in Language.C.Inline.Context from the package inline-c
    -- IMPORTANT: When using the @fun@ anti quoter, one must be aware that
    -- the function pointer which is automatically generated is freed when
    -- the code contained in the block containing the anti quoter exits.
    -- Thus, if you need the function pointer to be longer-lived, you must
    -- allocate it and free it manually using 'freeHaskellFunPtr'.
    -- We provide utilities to easily
    -- allocate them (see 'Language.C.Inline.mkFunPtr').
    --
    -- IMPORTANT: When using the @fun-alloc@ anti quoter, one must free the allocated
    -- function pointer. The GHC runtime provides a function to do this,
    -- 'hs_free_fun_ptr' available in the 'HsFFI.h' header.
    
    funCtx :: Context
    funCtx = mempty
      { ctxAntiQuoters = Map.fromList [("fun", SomeAntiQuoter funPtrAntiQuoter)
                                      ,("fun-alloc", SomeAntiQuoter funAllocPtrAntiQuoter)]
      }
    
    funPtrAntiQuoter :: AntiQuoter HaskellIdentifier
    funPtrAntiQuoter = AntiQuoter
    

    Found in Language.C.Inline.Context from the package inline-c
        Just hsName -> TH.varE hsName
    
    convertType_ :: String -> Purity -> TypesTable -> C.Type C.CIdentifier -> TH.Q TH.Type
    convertType_ err purity cTypes cTy = do
      mbHsType <- convertType purity cTypes cTy
      case mbHsType of
        Nothing -> fail $ "Cannot convert C type (" ++ err ++ ")"
        Just hsType -> return hsType
    
    -- | This 'Context' adds support for 'ForeignPtr' arguments. It adds a unique
    -- marshaller called @fptr-ptr@. For example, @$fptr-ptr:(int *x)@ extracts the
    -- bare C pointer out of foreign pointer @x@.
    fptrCtx :: Context
    fptrCtx = mempty
      { ctxAntiQuoters = Map.fromList [("fptr-ptr", SomeAntiQuoter fptrAntiQuoter)]
      }
    
    fptrAntiQuoter :: AntiQuoter HaskellIdentifier
    fptrAntiQuoter = AntiQuoter
      { aqParser = cDeclAqParser
    

    Found in Language.C.Inline.Context from the package inline-c
            hsTy <- go cTy'
            lift [t| CArray $(return hsTy) |]
          C.Proto _retType _pars -> do
            -- We cannot convert standalone prototypes
            mzero
    
        buildArr [] hsRetType =
          case purity of
            Pure -> [t| $(return hsRetType) |]
            IO -> [t| IO $(return hsRetType) |]
        buildArr (hsPar : hsPars) hsRetType =
          [t| $(return hsPar) -> $(buildArr hsPars hsRetType) |]
    
    typeNamesFromTypesTable :: TypesTable -> C.TypeNames
    typeNamesFromTypesTable cTypes = HashSet.fromList
      [ id' | C.TypeName id' <- Map.keys cTypes ]
    
    ------------------------------------------------------------------------
    -- Useful contexts
    

    Found in Language.C.Inline.Context from the package inline-c
    #endif
    
    -- | Context useful to work with vanilla C. Used by default.
    --
    -- 'ctxTypesTable': converts C basic types to their counterparts in
    -- "Foreign.C.Types".
    --
    -- No 'ctxAntiQuoters'.
    baseCtx :: Context
    baseCtx = mempty
      { ctxTypesTable = baseTypesTable
      }
    
    baseTypesTable :: Map.Map C.TypeSpecifier TH.TypeQ
    baseTypesTable = Map.fromList
      [ (C.Void, [t| () |])
      -- Types from Foreign.C.Types in the order in which they are presented there,
      -- along with its documentation's section headers.
      --
      -- Integral types
    

    Found in Language.C.Inline.HaskellIdentifier from the package inline-c
    haskellIdentStyle = IdentifierStyle
      { _styleName = "Haskell identifier"
      , _styleStart = small
      , _styleLetter = small <|> large <|> digit <|> char '\''
      , _styleReserved = haskellReservedWords
      , _styleHighlight = Highlight.Identifier
      , _styleReservedHighlight = Highlight.ReservedIdentifier
      }
      where
        small = lower <|> char '_'
        large = upper
    
    -- We disallow both Haskell reserved words and C reserved words.
    haskellReservedWords :: HashSet.HashSet String
    haskellReservedWords = C.cReservedWords <> HashSet.fromList
      [ "case", "class", "data", "default", "deriving", "do", "else"
      , "foreign", "if", "import", "in", "infix", "infixl"
      , "infixr", "instance", "let", "module", "newtype", "of"
      , "then", "type", "where"
      ]
    

    Found in Language.C.Types.Parse from the package inline-c
      Right x -> x
    
    -- | Like 'quickCParser', but uses @'cCParserContext' ('const' 'False')@ as
    -- 'CParserContext'.
    quickCParser_
      :: String
      -- ^ String to parse.
      -> (ReaderT (CParserContext CIdentifier) (Parsec.Parsec String ()) a)
      -- ^ Parser.  Anything with type @forall m. CParser i m => m a@ is a
      -- valid argument.
      -> a
    quickCParser_ = quickCParser (cCParserContext HashSet.empty)
    
    cReservedWords :: HashSet.HashSet String
    cReservedWords = HashSet.fromList
      [ "auto", "else", "long", "switch"
      , "break", "enum", "register", "typedef"
      , "case", "extern", "return", "union"
      , "char", "float", "short", "unsigned"
      , "const", "for", "signed", "void"
    

    Found in Text.Html.IsLink from the package islink
    isLinkAttr tag attr = HS.member (tag, attr) allLinkAttrs
    
    -- sources:
    --     * The HTML 4.01 transitional DTD
    --     * The HTML 4.01 strict DTD
    --     * The HTML 3.2 DTD
    --     * The HTML 3.0 DTD
    --     * The XMLmind XML Editor 6.0.0 Evaluation Edition contains
    --       a BSD licensed W3C XML Schema file for HTML 5
    --     * The HTML::Tagset perl module (version 3.20)
    -- see the scripts/ directory for more details
    -- | A 'HashSet' that contains all combinations of tag names and attributes
    -- that correspond to links.
    allLinkAttrs :: HashSet (String, String)
    allLinkAttrs = HS.fromList
        [ ("a", "href")
        , ("applet", "archive")
        , ("applet", "code")
        , ("applet", "codebase")
        , ("area", "href")
    

    Found in Math.MFSolve from the package mfsolve
    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
    -- the number of eliminated equations.
    -- 
    

    Found in Math.MFSolve from the package mfsolve
                   | 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')
    
    addEq0 :: (Hashable v, Hashable n, RealFrac (Phase n), Ord v, Floating n) => Dependencies v n -> Expr v n -> Expr v n -> Either (DepError v n) (Dependencies v n)
    -- adding a constant equation
    addEq0 _ e (ConstE c) =
    

    Found in Text.Parser.Token.Style from the package parsers
          <|> skipSome (noneOf startEnd) *> inCommentMulti
          <|> oneOf startEnd *> inCommentMulti
          <?> "end of comment"
    
        startEnd = nub (endStyle ++ startStyle)
    
        inCommentSingle :: m ()
        inCommentSingle
          =   () <$ try (string endStyle)
          <|> skipSome (noneOf startEnd) *> inCommentSingle
          <|> oneOf startEnd *> inCommentSingle
          <?> "end of comment"
    
    set :: [String] -> HashSet String
    set = HashSet.fromList
    
    -- | A simple operator style based on haskell with no reserved operators
    emptyOps :: TokenParsing m => IdentifierStyle m
    emptyOps = IdentifierStyle
      { _styleName     = "operator"
    

    Found in Test.QuickCheck.Instances.UnorderedContainers from the package quickcheck-instances
    -- unordered-containers
    -------------------------------------------------------------------------------
    
    instance (Hashable a, Eq a, Arbitrary a) => Arbitrary (HS.HashSet a) where
        arbitrary = HS.fromList <$> arbitrary
        shrink hashset = HS.fromList <$> shrink (HS.toList hashset)
    
    instance CoArbitrary a => CoArbitrary (HS.HashSet a) where
        coarbitrary = coarbitrary . HS.toList
    
    instance (Hashable k, Eq k, Arbitrary k) => Arbitrary1 (HML.HashMap k) where
        liftArbitrary arb =
            HML.fromList <$> liftArbitrary (liftArbitrary2 arbitrary arb)
        liftShrink shr m =
            HML.fromList <$> liftShrink (liftShrink2 shrink shr) (HML.toList m)
    
    instance (Hashable k, Eq k, Arbitrary k, Arbitrary v) => Arbitrary (HML.HashMap k v) where
        arbitrary = arbitrary1
        shrink = shrink1
    

    Found in Test.QuickCheck.Instances.UnorderedContainers from the package quickcheck-instances
    -------------------------------------------------------------------------------
    -- unordered-containers
    -------------------------------------------------------------------------------
    
    instance (Hashable a, Eq a, Arbitrary a) => Arbitrary (HS.HashSet a) where
        arbitrary = HS.fromList <$> arbitrary
        shrink hashset = HS.fromList <$> shrink (HS.toList hashset)
    
    instance CoArbitrary a => CoArbitrary (HS.HashSet a) where
        coarbitrary = coarbitrary . HS.toList
    
    instance (Hashable k, Eq k, Arbitrary k) => Arbitrary1 (HML.HashMap k) where
        liftArbitrary arb =
            HML.fromList <$> liftArbitrary (liftArbitrary2 arbitrary arb)
        liftShrink shr m =
            HML.fromList <$> liftShrink (liftShrink2 shrink shr) (HML.toList m)
    
    instance (Hashable k, Eq k, Arbitrary k, Arbitrary v) => Arbitrary (HML.HashMap k v) where
        arbitrary = arbitrary1
    

    Found in Test.QuickCheck.Instances.UnorderedContainers from the package quickcheck-instances
    import Data.Hashable (Hashable)
    
    import Test.QuickCheck
    
    import qualified Data.HashMap.Lazy as HML
    import qualified Data.HashSet as HS
    
    -------------------------------------------------------------------------------
    -- unordered-containers
    -------------------------------------------------------------------------------
    
    instance (Hashable a, Eq a, Arbitrary a) => Arbitrary (HS.HashSet a) where
        arbitrary = HS.fromList <$> arbitrary
        shrink hashset = HS.fromList <$> shrink (HS.toList hashset)
    
    instance CoArbitrary a => CoArbitrary (HS.HashSet a) where
        coarbitrary = coarbitrary . HS.toList
    
    instance (Hashable k, Eq k, Arbitrary k) => Arbitrary1 (HML.HashMap k) where
    

    Found in Test.QuickCheck.Instances.UnorderedContainers from the package quickcheck-instances
    import Prelude.Compat
    
    import Data.Hashable (Hashable)
    
    import Test.QuickCheck
    
    import qualified Data.HashMap.Lazy as HML
    import qualified Data.HashSet as HS
    
    -------------------------------------------------------------------------------
    -- unordered-containers
    -------------------------------------------------------------------------------
    
    instance (Hashable a, Eq a, Arbitrary a) => Arbitrary (HS.HashSet a) where
        arbitrary = HS.fromList <$> arbitrary
        shrink hashset = HS.fromList <$> shrink (HS.toList hashset)
    
    instance CoArbitrary a => CoArbitrary (HS.HashSet a) where
        coarbitrary = coarbitrary . HS.toList
    

    Found in Relude.Container.Reexport from the package relude
           , module Data.Set
           , module Data.Tuple
           , module GHC.Exts
           ) where
    
    import Data.Hashable (Hashable (hashWithSalt))
    import Data.HashMap.Strict (HashMap)
    import Data.HashSet (HashSet)
    import Data.IntMap.Strict (IntMap)
    import Data.IntSet (IntSet)
    import Data.Map.Strict (Map)
    import Data.Sequence (Seq)
    import Data.Set (Set)
    import Data.Tuple (curry, fst, snd, swap, uncurry)
    import GHC.Exts (IsList (fromList, fromListN))
    

    Found in Relude.Nub from the package relude
    >>> sortNub [3, 3, 3, 2, 2, -1, 1]
    [-1,1,2,3]
    
    -}
    sortNub :: (Ord a) => [a] -> [a]
    sortNub = Set.toList . Set.fromList
    
    {- | Like 'hashNub' but has better performance and also doesn't save the order.
    
    >>> unstableNub [3, 3, 3, 2, 2, -1, 1]
    [1,2,3,-1]
    
    -}
    unstableNub :: (Eq a, Hashable a) => [a] -> [a]
    unstableNub = HashSet.toList . HashSet.fromList
    

    Found in Relude.Nub from the package relude
      where
        go _ []     = []
        go s (x:xs) =
          if x `HashSet.member` s
          then go s xs
          else x : go (HashSet.insert x s) xs
    
    {- | Like 'ordNub' but also sorts a list.
    
    >>> sortNub [3, 3, 3, 2, 2, -1, 1]
    [-1,1,2,3]
    
    -}
    sortNub :: (Ord a) => [a] -> [a]
    sortNub = Set.toList . Set.fromList
    
    {- | Like 'hashNub' but has better performance and also doesn't save the order.
    
    >>> unstableNub [3, 3, 3, 2, 2, -1, 1]
    [1,2,3,-1]
    

    Found in RIO.HashSet from the package rio
      , Data.HashSet.difference
      , Data.HashSet.intersection
    
      -- * Folds
      , Data.HashSet.foldl'
      , Data.HashSet.foldr
    
      -- * Filter
      , Data.HashSet.filter
    
      -- * Conversions
    
      -- ** Lists
      , Data.HashSet.toList
      , Data.HashSet.fromList
    
      -- * HashMaps
      , Data.HashSet.toMap
      , Data.HashSet.fromMap
      ) where
    

    Found in Data.Swagger.Internal.Schema from the package swagger2
    -- If it is encoded with 'ToJSONKeyValue' then a regular schema for @[(key, value)]@ is used.
    declareSchemaBoundedEnumKeyMapping :: forall map key value proxy.
      (Bounded key, Enum key, ToJSONKey key, ToSchema key, ToSchema value)
      => proxy (map key value) -> Declare (Definitions Schema) Schema
    declareSchemaBoundedEnumKeyMapping _ = case toJSONKey :: ToJSONKeyFunction key of
      ToJSONKeyText keyToText _ -> objectSchema keyToText
      ToJSONKeyValue _ _ -> declareSchema (Proxy :: Proxy [(key, value)])
      where
        objectSchema keyToText = do
          valueRef <- declareSchemaRef (Proxy :: Proxy value)
          let allKeys   = [minBound..maxBound :: key]
              mkPair k  =  (keyToText k, valueRef)
          return $ mempty
            & type_ .~ SwaggerObject
            & properties .~ InsOrdHashMap.fromList (map mkPair allKeys)
    
    -- | A 'Schema' for a mapping with 'Bounded' 'Enum' keys.
    -- This makes a much more useful schema when there aren't many options for key values.
    --
    -- >>> data ButtonState = Neutral | Focus | Active | Hover | Disabled deriving (Show, Bounded, Enum, Generic)
    

    Found in Data.Swagger.Internal.Schema from the package swagger2
          & type_       .~ SwaggerNumber
          & maximum_    ?~ n
          & minimum_    ?~ n
          & multipleOf  ?~ n
          & enum_       ?~ [js]
        go js@(Array xs) = mempty
          & type_       .~ SwaggerArray
          & maxItems    ?~ fromIntegral sz
          & minItems    ?~ fromIntegral sz
          & items       ?~ SwaggerItemsArray (map (Inline . go) (V.toList xs))
          & uniqueItems ?~ allUnique
          & enum_       ?~ [js]
          where
            sz = length xs
            allUnique = sz == HashSet.size (HashSet.fromList (V.toList xs))
        go js@(Object o) = mempty
          & type_         .~ SwaggerObject
          & required      .~ names
          & properties    .~ fmap (Inline . go) (InsOrdHashMap.fromHashMap o)
          & maxProperties ?~ fromIntegral (length names)
    

    Found in Data.Swagger.Internal.Schema.Validation from the package swagger2
      check items $ \case
        SwaggerItemsPrimitive _ itemSchema -> sub itemSchema $ traverse_ validateWithParamSchema xs
        SwaggerItemsObject itemSchema      -> traverse_ (validateWithSchemaRef itemSchema) xs
        SwaggerItemsArray itemSchemas -> do
          when (len /= length itemSchemas) $
            invalid ("array size is invalid (should be exactly " ++ show (length itemSchemas) ++ ")")
          sequenceA_ (zipWith validateWithSchemaRef itemSchemas (Vector.toList xs))
    
      check uniqueItems $ \unique ->
        when (unique && not allUnique) $
          invalid ("array is expected to contain unique items, but it does not")
      where
        len = Vector.length xs
        allUnique = len == HashSet.size (HashSet.fromList (Vector.toList xs))
    
    validateObject :: HashMap Text Value -> Validation Schema ()
    validateObject o = withSchema $ \sch ->
      case sch ^. discriminator of
        Just pname -> case fromJSON <$> HashMap.lookup pname o of
    

    Found in Control.Concurrent.STM.TMapChan.Hash from the package tmapchan
      modifyTVar' xs (HashMap.insert k c)
    
    -- | Clones all the content from every channel, and inserts the unique subset of them to `k`, in an unspecified order.
    cloneAllUniquely :: ( Eq k, Hashable k
                        , Eq a, Hashable a
                        )
                      => TMapChan k a
                      -> k
                      -> STM ()
    cloneAllUniquely t@(TMapChan xs) k = do
      as <- readTVar xs
      c <- newTChan
      as' <- newTVar HashSet.empty
      forM_ (HashMap.keys as) $ \k' -> do
        as'More <- HashSet.fromList <$> observeAll t k'
        modifyTVar' as' (HashSet.union as'More)
      as'All <- HashSet.toList <$> readTVar as'
      forM_ as'All (writeTChan c)
      modifyTVar' xs (HashMap.insert k c)
    

    Found in Data.TreeDiff.Class from the package tree-diff
        (constructorInfo di)
        xss
      where
        isNewtype = case di of
            Newtype _ _ _ -> True
            ADT _ _ _     -> False
    
    sopNPToExpr :: All ToExpr xs => Bool -> ConstructorInfo xs -> NP I xs -> Expr
    sopNPToExpr _ (Infix cn _ _) xs = App ("_" ++ cn ++ "_") $ hcollapse $
        hcmap (Proxy :: Proxy ToExpr) (mapIK toExpr) xs
    sopNPToExpr _ (Constructor cn) xs = App cn $ hcollapse $
        hcmap (Proxy :: Proxy ToExpr) (mapIK toExpr) xs
    sopNPToExpr True (Record cn _) xs = App cn $ hcollapse $
        hcmap (Proxy :: Proxy ToExpr) (mapIK toExpr) xs
    sopNPToExpr False (Record cn fi) xs = Rec cn $ Map.fromList $ hcollapse $
        hcliftA2 (Proxy :: Proxy ToExpr) mk fi xs
      where
        mk :: ToExpr x => FieldInfo x -> I x -> K (FieldName, Expr) x
        mk (FieldInfo fn) (I x) = K (fn, toExpr x)
    

    Found in Data.Unfoldable.Restricted from the package unfoldable-restricted
    unfoldRestrictBF :: (UnfoldableR p t, Unfolder f, p a) => f a -> f (t a)
    unfoldRestrictBF = ala bfs unfoldRestrict
    
    unfoldRestrictBF_ :: (UnfoldableR Unit t, Unfolder f) => f (t ())
    unfoldRestrictBF_ = bfs unfoldRestrict_
    
    unfoldrRestrict :: (UnfoldableR p t, p a) => (b -> Maybe (a, b)) -> b -> Maybe (t a)
    unfoldrRestrict f z = terminate . flip runStateT z . unfoldRestrictBF . StateT $ maybeToList . f
      where
        terminate []          = Nothing
        terminate ((t, b):ts) = if isNothing (f b) then Just t else terminate ts
    
    fromList :: (UnfoldableR p t, p a) => [a] -> Maybe (t a)
    fromList = unfoldrRestrict uncons
      where
        uncons []     = Nothing
        uncons (a:as) = Just (a, as)
    
    leftMost :: (UnfoldableR Unit t) => Maybe (t ())
    

    Found in Data.Unfoldable.Restricted from the package unfoldable-restricted
    unfoldRestrict_ = unfoldRestrict (pure ())
    
    unfoldRestrictBF :: (UnfoldableR p t, Unfolder f, p a) => f a -> f (t a)
    unfoldRestrictBF = ala bfs unfoldRestrict
    
    unfoldRestrictBF_ :: (UnfoldableR Unit t, Unfolder f) => f (t ())
    unfoldRestrictBF_ = bfs unfoldRestrict_
    
    unfoldrRestrict :: (UnfoldableR p t, p a) => (b -> Maybe (a, b)) -> b -> Maybe (t a)
    unfoldrRestrict f z = terminate . flip runStateT z . unfoldRestrictBF . StateT $ maybeToList . f
      where
        terminate []          = Nothing
        terminate ((t, b):ts) = if isNothing (f b) then Just t else terminate ts
    
    fromList :: (UnfoldableR p t, p a) => [a] -> Maybe (t a)
    fromList = unfoldrRestrict uncons
      where
        uncons []     = Nothing
        uncons (a:as) = Just (a, as)
    

    Found in Universum.Nub from the package universum
    -- | Like 'ordNub' but also sorts a list.
    --
    -- >>> sortNub [3, 3, 3, 2, 2, -1, 1]
    -- [-1,1,2,3]
    {-@ sortNub :: [a] -> ListUnique a @-}
    sortNub :: (Ord a) => [a] -> [a]
    sortNub = Set.toList . Set.fromList
    
    -- | Like 'hashNub' but has better performance and also doesn't save the order.
    --
    -- >>> unstableNub [3, 3, 3, 2, 2, -1, 1]
    -- [1,2,3,-1]
    unstableNub :: (Eq a, Hashable a) => [a] -> [a]
    unstableNub = HashSet.toList . HashSet.fromList
    

    Found in Universum.Nub from the package universum
    hashNub = go HashSet.empty
      where
        go _ []     = []
        go s (x:xs) =
          if x `HashSet.member` s
          then go s xs
          else x : go (HashSet.insert x s) xs
    
    -- | Like 'ordNub' but also sorts a list.
    --
    -- >>> sortNub [3, 3, 3, 2, 2, -1, 1]
    -- [-1,1,2,3]
    {-@ sortNub :: [a] -> ListUnique a @-}
    sortNub :: (Ord a) => [a] -> [a]
    sortNub = Set.toList . Set.fromList
    
    -- | Like 'hashNub' but has better performance and also doesn't save the order.
    --
    -- >>> unstableNub [3, 3, 3, 2, 2, -1, 1]
    -- [1,2,3,-1]
    

    fromMap See 2 Occurences [+] Collapse [-]
    Found in Database.Beam.Migrate.Actions from the package beam-migrate
                       _ -> 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)
        reject mdbState q =
          let q' = PQ.insert mdbState q
          in PQ.fromAscList (PQ.take rejectedCount q')
    
        dbStateAfterAction (DatabaseState curState _ cmds) action =
          let curState' = ((curState `HM.difference` HS.toMap (actionPreConditions action))
                         `HM.union` (DatabaseStateSourceDerived <$ HS.toMap (actionPostConditions action)))
          in DatabaseState curState' (HS.fromMap (() <$ curState'))
                           (cmds <> actionCommands action)
    

    Found in RIO.HashSet from the package rio
      , Data.HashSet.foldl'
      , Data.HashSet.foldr
    
      -- * Filter
      , Data.HashSet.filter
    
      -- * Conversions
    
      -- ** Lists
      , Data.HashSet.toList
      , Data.HashSet.fromList
    
      -- * HashMaps
      , Data.HashSet.toMap
      , Data.HashSet.fromMap
      ) where
    
    import qualified Data.HashSet
    

    insert See 44 Occurences [+] Collapse [-]
    Found in Database.Beam.Migrate.Actions from the package beam-migrate
                        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)
        reject mdbState q =
          let q' = PQ.insert mdbState q
          in PQ.fromAscList (PQ.take rejectedCount q')
    
        dbStateAfterAction (DatabaseState curState _ cmds) action =
          let curState' = ((curState `HM.difference` HS.toMap (actionPreConditions action))
                         `HM.union` (DatabaseStateSourceDerived <$ HS.toMap (actionPostConditions action)))
    

    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)
        reject mdbState q =
    

    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.Simple from the package beam-migrate
                  executeMigration (\_ -> pure ()) step)
    
      if shouldRunMigration
        then Just <$>
             runMigrationSteps (lastCommit + 1) Nothing steps
               (\stepIx stepName step ->
                  do startStepHook hooks stepIx stepName
                     ret <-
                       executeMigration
                         (\cmd -> do
                             runCommandHook hooks stepIx (renderSyntax' cmd)
                             runNoReturn cmd)
                         step
    
                     runInsert $ insert (_beamMigrateLogEntries (beamMigrateDb @be @cmd @hdl @m)) $
                       insertExpressions [ LogEntry (val_ stepIx) (val_ stepName) currentTimestamp_ ]
                     endStepHook hooks stepIx stepName
    
                     return ret)
        else pure Nothing
    

    Found in Control.Foldl from the package foldl
    map = Fold step begin done
      where
        begin = mempty
        step m (k, v) = Map.insert k v m
        done = id
    {-# INLINABLE map #-}
    
    {-|
    Fold pairs into a hash-map.
    -}
    hashMap :: (Eq a, Hashable a) => Fold (a, b) (HashMap.HashMap a b)
    hashMap = Fold step begin done
      where
        begin = mempty
        step m (k, v) = HashMap.insert k v m
        done = id
    {-# INLINABLE hashMap #-}
    
    -- | Fold all values into a vector
    vector :: Vector v a => Fold a (v a)
    

    Found in Control.Foldl from the package foldl
    {-# INLINABLE set #-}
    
    -- | Fold values into a hash-set
    hashSet :: (Eq a, Hashable a) => Fold a (HashSet.HashSet a)
    hashSet = Fold (flip HashSet.insert) HashSet.empty id
    {-# INLINABLE hashSet #-}
    
    {-|
    Fold pairs into a map.
    -}
    map :: Ord a => Fold (a, b) (Map.Map a b)
    map = Fold step begin done
      where
        begin = mempty
        step m (k, v) = Map.insert k v m
        done = id
    {-# INLINABLE map #-}
    
    {-|
    Fold pairs into a hash-map.
    

    Found in Control.Foldl from the package foldl
      where
        step (Pair known r) a = if List.elem a known
          then Pair known r
          else Pair (a : known) (r . (a :))
        fin (Pair _ r) = r []
    {-# INLINABLE eqNub #-}
    
    -- | Fold values into a set
    set :: Ord a => Fold a (Set.Set a)
    set = Fold (flip Set.insert) Set.empty id
    {-# INLINABLE set #-}
    
    -- | Fold values into a hash-set
    hashSet :: (Eq a, Hashable a) => Fold a (HashSet.HashSet a)
    hashSet = Fold (flip HashSet.insert) HashSet.empty id
    {-# INLINABLE hashSet #-}
    
    {-|
    Fold pairs into a map.
    -}
    

    Found in Control.Foldl from the package foldl
    {-| /O(n^2)/.  Fold values into a list with duplicates removed, while preserving
        their first occurrences
    -}
    eqNub :: Eq a => Fold a [a]
    eqNub = Fold step (Pair [] id) fin
      where
        step (Pair known r) a = if List.elem a known
          then Pair known r
          else Pair (a : known) (r . (a :))
        fin (Pair _ r) = r []
    {-# INLINABLE eqNub #-}
    
    -- | Fold values into a set
    set :: Ord a => Fold a (Set.Set a)
    set = Fold (flip Set.insert) Set.empty id
    {-# INLINABLE set #-}
    
    -- | Fold values into a hash-set
    hashSet :: (Eq a, Hashable a) => Fold a (HashSet.HashSet a)
    hashSet = Fold (flip HashSet.insert) HashSet.empty id
    

    Found in Control.Foldl from the package foldl
    -- | Fold all values into a list, in reverse order
    revList :: Fold a [a]
    revList = Fold (\x a -> a:x) [] id
    {-# INLINABLE revList #-}
    
    {-| /O(n log n)/.  Fold values into a list with duplicates removed, while
        preserving their first occurrences
    -}
    nub :: Ord a => Fold a [a]
    nub = Fold step (Pair Set.empty id) fin
      where
        step (Pair s r) a = if Set.member a s
          then Pair s r
          else Pair (Set.insert a s) (r . (a :))
        fin (Pair _ r) = r []
    {-# INLINABLE nub #-}
    
    {-| /O(n^2)/.  Fold values into a list with duplicates removed, while preserving
        their first occurrences
    

    Found in Data.Core.Graph.PureCore from the package graph-core
    hullFoldM :: Monad m => Graph -> (b -> Node -> m b) -> b -> Node -> m b
    hullFoldM g = hullFoldImpl (g_adj g)
    
    hullFoldImpl :: Monad m => AdjList -> (b -> Node -> m b) -> b -> Node -> m b
    hullFoldImpl adj f initial root =
        go IS.empty initial [root]
        where
          go _ acc [] = return acc
          go !visited !acc (x:xs) =
              if (IS.member x visited)
              then go visited acc xs
              else do newAcc <- f acc x
                      let succs = IM.findWithDefault VU.empty x adj
                      go (IS.insert x visited) newAcc (xs ++ VU.toList succs)
    

    Found in Data.Core.Graph.PureCore from the package graph-core
    hull :: Graph -> Node -> NodeSet
    hull g = hullImpl g (g_adj g)
    
    rhull :: Graph -> Node -> NodeSet
    rhull g = hullImpl g (g_radj g)
    
    hullImpl :: Graph -> AdjList -> Node -> NodeSet
    hullImpl (Graph{..}) adj root =
        runST $
           do vis <- newSTRef IS.empty
              let go x =
                   (IS.member x <$> readSTRef vis) >>=
                      (flip unless $
                         do modifySTRef' vis (IS.insert x)
                            VU.forM_ (IM.findWithDefault VU.empty x adj) go)
              go root
              readSTRef vis
    
    rhullFold :: Graph -> (b -> Node -> b) -> b -> Node -> b
    

    Found in Data.Core.Graph.PureCore from the package graph-core
    fromEdges :: [Edge] -> Graph
    fromEdges edgeList =
        Graph { g_adj = mkAdj edgeList
              , g_radj = mkAdj $ map invert edgeList
              }
        where
          mkAdj e = IM.fromList $ map (src . head &&& VU.fromList . map tgt)
                            . L.groupBy ((==) `on` src)
                            . L.sortBy (compare `on` src) $ e
    
    fromAdj :: [(Node, [Node])] -> Graph
    fromAdj l =
        let g1 = fromEdges (adjToEdges l)
            solitaires = map fst $ filter (\(_, xs) -> null xs) l
        in L.foldl' (\g n -> g { g_adj = IM.insert n VU.empty (g_adj g) }) g1 solitaires
    
    nodes :: Graph -> [Node]
    nodes g = IM.keys (IM.union (g_adj g) (g_radj g))
    
    edges :: Graph -> [Edge]
    

    Found in Data.Greskell.GraphSON from the package greskell-core
          parse = parseToGMapEntry parseGraphSON parseGraphSON
    
    
    ---- Map instances
    
    instance (FromGraphSON v, Eq k, Hashable k, FromJSONKey k, FromGraphSON k) => FromGraphSON (L.HashMap k v) where
      parseGraphSON = fmap unGMap . parseGraphSON
    instance (FromGraphSON v, Ord k, FromJSONKey k, FromGraphSON k) => FromGraphSON (L.Map k v) where
      parseGraphSON = fmap unGMap . parseGraphSON
    -- IntMap cannot be used with GMap directly..
    instance FromGraphSON v => FromGraphSON (L.IntMap v) where
      parseGraphSON = fmap (mapToIntMap . unGMap) . parseGraphSON
        where
          mapToIntMap :: L.Map Int v -> L.IntMap v
          mapToIntMap = LMap.foldrWithKey LIntMap.insert mempty
    
    ---- Maybe and Either
    
    -- | Parse 'GNull' into 'Nothing'.
    instance FromGraphSON a => FromGraphSON (Maybe a) where
    

    Found in Haxl.Core.Profile from the package haxl
    modifyProfileData :: Env u -> ProfileLabel -> AllocCount -> IO ()
    modifyProfileData env label allocs =
      modifyIORef' (profRef env) $ \ p ->
        p { profile =
              HashMap.insertWith updEntry label newEntry .
              HashMap.insertWith updCaller caller newCaller $
              profile p }
      where caller = profLabel env
            newEntry =
              emptyProfileData
                { profileAllocs = allocs
                , profileDeps = HashSet.singleton caller }
            updEntry _ old =
              old { profileAllocs = profileAllocs old + allocs
                  , profileDeps = HashSet.insert caller (profileDeps old) }
            -- subtract allocs from caller, so they are not double counted
            -- we don't know the caller's caller, but it will get set on
            -- the way back out, so an empty hashset is fine for now
            newCaller =
              emptyProfileData { profileAllocs = -allocs }
    

    Found in LLVM.IRBuilder.Monad from the package llvm-hs-pure
    -- | Generate a fresh name. The resulting name is numbered or
    -- based on the name suggested with 'named' if that's used.
    fresh :: MonadIRBuilder m => m Name
    fresh = do
      msuggestion <- liftIRState $ gets builderNameSuggestion
      maybe freshUnName freshName msuggestion
    
    -- | Generate a fresh name from a name suggestion
    freshName :: MonadIRBuilder m => ShortByteString -> m Name
    freshName suggestion = do
      usedNames <- liftIRState $ gets builderUsedNames
      let
        candidates = suggestion : [suggestion <> fromString (show n) | n <- [(1 :: Int)..]]
        (unusedName:_) = filter (not . (`HS.member` usedNames)) candidates
      liftIRState $ modify $ \s -> s { builderUsedNames = HS.insert unusedName $ builderUsedNames s }
      return $ Name unusedName
    
    -- | Generate a fresh numbered name
    freshUnName :: MonadIRBuilder m => m Name
    freshUnName = liftIRState $ do
    

    Found in Math.MFSolve from the package mfsolve
              -- use addEq0 since substitution is unnecessary
             in case foldM (flip addEq0 zeroExpr)
                     deps $
                     map (subst $ simpleSubst v lt2)
                     (trig'++trig2'++nonlin) of
                 Left _ -> (deps, e) --shouldn't happen
                 Right d -> (d, e)
      | otherwise =
          let (l, trig2') =
                M.foldrWithKey trigFold
                ([], M.empty) trig2
              trigFold p t (l2, m2) =
                let (l3, m1) = elimTrig p t v
                    mp | M.null m1 = m2
                       | otherwise = M.insert p m1 m2
                in (l3++l2, mp)
                
              (nlWith, nlWithout) =
                partition (hasVar v) $
                map trigToExpr trig ++ nonlin
    

    Found in Math.MFSolve from the package mfsolve
    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
          -- 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
    

    Found in Math.MFSolve from the package mfsolve
    select (x:xs) =
      (x,xs) : [(y,x:ys) | (y,ys) <- select xs]
    
    -- 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
    

    Found in Relude.Nub from the package relude
    {- | Like 'Prelude.nub' but runs in @O(n * log_16(n))@ time and requires 'Hashable'.
    
    >>> hashNub [3, 3, 3, 2, 2, -1, 1]
    [3,2,-1,1]
    
    -}
    hashNub :: (Eq a, Hashable a) => [a] -> [a]
    hashNub = go HashSet.empty
      where
        go _ []     = []
        go s (x:xs) =
          if x `HashSet.member` s
          then go s xs
          else x : go (HashSet.insert x s) xs
    
    {- | Like 'ordNub' but also sorts a list.
    
    >>> sortNub [3, 3, 3, 2, 2, -1, 1]
    [-1,1,2,3]
    

    Found in Relude.Nub from the package relude
    {- | Like 'Prelude.nub' but runs in @O(n * log n)@ time and requires 'Ord'.
    
    >>> ordNub [3, 3, 3, 2, 2, -1, 1]
    [3,2,-1,1]
    
    -}
    ordNub :: (Ord a) => [a] -> [a]
    ordNub = go Set.empty
      where
        go _ []     = []
        go s (x:xs) =
          if x `Set.member` s
          then go s xs
          else x : go (Set.insert x s) xs
    
    {- | Like 'Prelude.nub' but runs in @O(n * log_16(n))@ time and requires 'Hashable'.
    
    >>> hashNub [3, 3, 3, 2, 2, -1, 1]
    [3,2,-1,1]
    

    Found in Relude.Extra.Map from the package relude
        delete     = HM.delete
        alter      = HM.alter
    
        {-# INLINE insert #-}
        {-# INLINE insertWith #-}
        {-# INLINE delete #-}
        {-# INLINE alter #-}
    
    instance DynamicMap (IntMap v) where
        insert     = IM.insert
        insertWith = IM.insertWith
        delete     = IM.delete
        alter      = IM.alter
    
        {-# INLINE insert #-}
        {-# INLINE insertWith #-}
        {-# INLINE delete #-}
        {-# INLINE alter #-}
    
    ----------------------------------------------------------------------------
    

    Found in Relude.Extra.Map from the package relude
        {-# INLINE alter #-}
    
    instance (Eq k, Hashable k) => DynamicMap (HashMap k v) where
        insert     = HM.insert
        insertWith = HM.insertWith
        delete     = HM.delete
        alter      = HM.alter
    
        {-# INLINE insert #-}
        {-# INLINE insertWith #-}
        {-# INLINE delete #-}
        {-# INLINE alter #-}
    
    instance DynamicMap (IntMap v) where
        insert     = IM.insert
        insertWith = IM.insertWith
        delete     = IM.delete
        alter      = IM.alter
    
        {-# INLINE insert #-}
    

    Found in Relude.Extra.Map from the package relude
        {-# INLINE alter #-}
    
    instance (Eq k, Hashable k) => DynamicMap (HashMap k v) where
        insert     = HM.insert
        insertWith = HM.insertWith
        delete     = HM.delete
        alter      = HM.alter
    
        {-# INLINE insert #-}
        {-# INLINE insertWith #-}
        {-# INLINE delete #-}
        {-# INLINE alter #-}
    
    instance DynamicMap (IntMap v) where
        insert     = IM.insert
        insertWith = IM.insertWith
        delete     = IM.delete
        alter      = IM.alter
    
        {-# INLINE insert #-}
    

    Found in Relude.Extra.Map from the package relude
        delete     = M.delete
        alter      = M.alter
    
        {-# INLINE insert #-}
        {-# INLINE insertWith #-}
        {-# INLINE delete #-}
        {-# INLINE alter #-}
    
    instance (Eq k, Hashable k) => DynamicMap (HashMap k v) where
        insert     = HM.insert
        insertWith = HM.insertWith
        delete     = HM.delete
        alter      = HM.alter
    
        {-# INLINE insert #-}
        {-# INLINE insertWith #-}
        {-# INLINE delete #-}
        {-# INLINE alter #-}
    
    instance DynamicMap (IntMap v) where
    

    Found in Relude.Extra.Map from the package relude
        alter :: (Maybe (Val t) -> Maybe (Val t)) -> Key t -> t -> t
    
    instance Ord k => DynamicMap (Map k v) where
        insert     = M.insert
        insertWith = M.insertWith
        delete     = M.delete
        alter      = M.alter
    
        {-# INLINE insert #-}
        {-# INLINE insertWith #-}
        {-# INLINE delete #-}
        {-# INLINE alter #-}
    
    instance (Eq k, Hashable k) => DynamicMap (HashMap k v) where
        insert     = HM.insert
        insertWith = HM.insertWith
        delete     = HM.delete
        alter      = HM.alter
    
        {-# INLINE insert #-}
    

    Found in Relude.Extra.Map from the package relude
        alter :: (Maybe (Val t) -> Maybe (Val t)) -> Key t -> t -> t
    
    instance Ord k => DynamicMap (Map k v) where
        insert     = M.insert
        insertWith = M.insertWith
        delete     = M.delete
        alter      = M.alter
    
        {-# INLINE insert #-}
        {-# INLINE insertWith #-}
        {-# INLINE delete #-}
        {-# INLINE alter #-}
    
    instance (Eq k, Hashable k) => DynamicMap (HashMap k v) where
        insert     = HM.insert
        insertWith = HM.insertWith
        delete     = HM.delete
        alter      = HM.alter
    
        {-# INLINE insert #-}
    

    Found in Relude.Extra.Map from the package relude
        -- insertions
        insert     :: Key t -> Val t -> t -> t
        insertWith :: (Val t -> Val t -> Val t) -> Key t -> Val t -> t -> t
    
        -- deletions
        delete :: Key t -> t -> t
        alter :: (Maybe (Val t) -> Maybe (Val t)) -> Key t -> t -> t
    
    instance Ord k => DynamicMap (Map k v) where
        insert     = M.insert
        insertWith = M.insertWith
        delete     = M.delete
        alter      = M.alter
    
        {-# INLINE insert #-}
        {-# INLINE insertWith #-}
        {-# INLINE delete #-}
        {-# INLINE alter #-}
    
    instance (Eq k, Hashable k) => DynamicMap (HashMap k v) where
    

    Found in Relude.Extra.Map from the package relude
    ----------------------------------------------------------------------------
    
    {- | Modifiable Map.
    -}
    class StaticMap t => DynamicMap t where
        -- insertions
        insert     :: Key t -> Val t -> t -> t
        insertWith :: (Val t -> Val t -> Val t) -> Key t -> Val t -> t -> t
    
        -- deletions
        delete :: Key t -> t -> t
        alter :: (Maybe (Val t) -> Maybe (Val t)) -> Key t -> t -> t
    
    instance Ord k => DynamicMap (Map k v) where
        insert     = M.insert
        insertWith = M.insertWith
        delete     = M.delete
        alter      = M.alter
    
        {-# INLINE insert #-}
    

    Found in Relude.Extra.Map from the package relude
    ----------------------------------------------------------------------------
    
    {- | Modifiable Map.
    -}
    class StaticMap t => DynamicMap t where
        -- insertions
        insert     :: Key t -> Val t -> t -> t
        insertWith :: (Val t -> Val t -> Val t) -> Key t -> Val t -> t -> t
    
        -- deletions
        delete :: Key t -> t -> t
        alter :: (Maybe (Val t) -> Maybe (Val t)) -> Key t -> t -> t
    
    instance Ord k => DynamicMap (Map k v) where
        insert     = M.insert
        insertWith = M.insertWith
        delete     = M.delete
        alter      = M.alter
    
        {-# INLINE insert #-}
    

    Found in Relude.Extra.Map from the package relude
                  -> Key t -- ^ Key to search
                  -> t     -- ^ Container to search
                  -> Val t
    lookupDefault def k = fromMaybe def . lookup k
    {-# INLINE lookupDefault #-}
    
    ----------------------------------------------------------------------------
    -- Dynamic Map
    ----------------------------------------------------------------------------
    
    {- | Modifiable Map.
    -}
    class StaticMap t => DynamicMap t where
        -- insertions
        insert     :: Key t -> Val t -> t -> t
        insertWith :: (Val t -> Val t -> Val t) -> Key t -> Val t -> t -> t
    
        -- deletions
        delete :: Key t -> t -> t
        alter :: (Maybe (Val t) -> Maybe (Val t)) -> Key t -> t -> t
    

    Found in RIO.HashSet from the package rio
        Data.HashSet.HashSet
    
      -- * Construction
      , Data.HashSet.empty
      , Data.HashSet.singleton
    
      -- * Combine
      , Data.HashSet.union
      , Data.HashSet.unions
    
      -- * Basic interface
      , Data.HashSet.null
      , Data.HashSet.size
      , Data.HashSet.member
      , Data.HashSet.insert
      , Data.HashSet.delete
    
      -- * Transformations
      , Data.HashSet.map
    

    Found in Database.Selda.Caching from the package selda
      | prio + 1 < prio  = cache' tns k v (emptyCache {maxItems = maxItems rc})
      | otherwise        = rc
        { results  = insert k prio v' results'
        , deps     = foldl' (\m tn -> M.alter (addTbl k) tn m) (deps rc) tns
        , nextPrio = prio + 1
        , items    = items'
        }
      where
        v' = toDyn v
        prio = nextPrio rc
        -- evict LRU element before inserting if full
        (items', results')
          | items rc >= maxItems rc = (items rc, deleteMin $ results rc)
          | otherwise               = (items rc + 1, results rc)
        addTbl key (Just ks) = Just (S.insert key ks)
        addTbl key Nothing   = Just (S.singleton key)
    
    -- | Get the cached value for the given key, if it exists.
    cached :: forall a. Typeable a => CacheKey -> IO (Maybe a)
    cached k = k `seqCK` atomicModifyIORef' theCache (cached' k)
    

    Found in Database.Selda.Caching from the package selda
    {-# NOINLINE theCache #-}
    theCache :: IORef ResultCache
    theCache = unsafePerformIO $ newIORef emptyCache
    
    -- | Cache the given value, with the given table dependencies.
    cache :: Typeable a => [TableName] -> CacheKey -> a -> IO ()
    cache tns k v = k `seqCK` atomicModifyIORef' theCache (\c -> (cache' tns k v c, ()))
    
    cache' :: Typeable a => [TableName] -> CacheKey -> a -> ResultCache -> ResultCache
    cache' tns k v rc
      | maxItems rc == 0 = rc
      | prio + 1 < prio  = cache' tns k v (emptyCache {maxItems = maxItems rc})
      | otherwise        = rc
        { results  = insert k prio v' results'
        , deps     = foldl' (\m tn -> M.alter (addTbl k) tn m) (deps rc) tns
        , nextPrio = prio + 1
        , items    = items'
        }
      where
    

    Found in Control.Concurrent.STM.TMapChan.Hash from the package tmapchan
                        , Eq a, Hashable a
                        )
                      => TMapChan k a
                      -> k
                      -> STM ()
    cloneAllUniquely t@(TMapChan xs) k = do
      as <- readTVar xs
      c <- newTChan
      as' <- newTVar HashSet.empty
      forM_ (HashMap.keys as) $ \k' -> do
        as'More <- HashSet.fromList <$> observeAll t k'
        modifyTVar' as' (HashSet.union as'More)
      as'All <- HashSet.toList <$> readTVar as'
      forM_ as'All (writeTChan c)
      modifyTVar' xs (HashMap.insert k c)
    

    Found in Control.Concurrent.STM.TMapChan.Hash from the package tmapchan
    cloneAt t@(TMapChan xs) kFrom kTo = do
      as <- observeAll t kFrom
      c <- newTChan
      forM_ as (writeTChan c)
      modifyTVar' xs (HashMap.insert kTo c)
    
    -- | Clones all the content for every key, by the key.
    cloneAll :: (Eq k, Hashable k) => TMapChan k a -> k -> STM ()
    cloneAll t@(TMapChan xs) k = do
      as <- readTVar xs
      c <- newTChan
      forM_ (HashMap.keys as) $ \k' -> do
        as' <- observeAll t k'
        forM_ as' (writeTChan c)
      modifyTVar' xs (HashMap.insert k c)
    
    -- | Clones all the content from every channel, and inserts the unique subset of them to `k`, in an unspecified order.
    cloneAllUniquely :: ( Eq k, Hashable k
                        , Eq a, Hashable a
                        )
    

    Found in Control.Concurrent.STM.TMapChan.Hash from the package tmapchan
    broadcast t@(TMapChan xs) a = do
      ks <- HashMap.keys <$> readTVar xs
      forM_ ks (\k -> insert t k a)
    
    
    cloneAt :: (Eq k, Hashable k)
            => TMapChan k a
            -> k -- ^ key to clone /from/
            -> k -- ^ key to clone /to/
            -> STM ()
    cloneAt t@(TMapChan xs) kFrom kTo = do
      as <- observeAll t kFrom
      c <- newTChan
      forM_ as (writeTChan c)
      modifyTVar' xs (HashMap.insert kTo c)
    
    -- | Clones all the content for every key, by the key.
    cloneAll :: (Eq k, Hashable k) => TMapChan k a -> k -> STM ()
    cloneAll t@(TMapChan xs) k = do
      as <- readTVar xs
    

    Found in Control.Concurrent.STM.TMapChan.Hash from the package tmapchan
      case HashMap.lookup k xs of
        Nothing -> do
          c' <- newTChan
          writeTVar t (HashMap.insert k c' xs)
          pure c'
        Just c' -> pure c'
    
    setTChan :: (Eq k, Hashable k) => TMapChan k a -> k -> TChan a -> STM ()
    setTChan (TMapChan t) k c = modifyTVar' t (HashMap.insert k c)
    
    
    broadcast :: (Eq k, Hashable k) => TMapChan k a -> a -> STM ()
    broadcast t@(TMapChan xs) a = do
      ks <- HashMap.keys <$> readTVar xs
      forM_ ks (\k -> insert t k a)
    
    
    cloneAt :: (Eq k, Hashable k)
            => TMapChan k a
            -> k -- ^ key to clone /from/
    

    Found in Control.Concurrent.STM.TMapChan.Hash from the package tmapchan
    -- | Creates a new one if it doesn't already exist
    getTChan :: (Eq k, Hashable k) => TMapChan k a -> k -> STM (TChan a)
    getTChan (TMapChan t) k = do
      xs <- readTVar t
      case HashMap.lookup k xs of
        Nothing -> do
          c' <- newTChan
          writeTVar t (HashMap.insert k c' xs)
          pure c'
        Just c' -> pure c'
    
    setTChan :: (Eq k, Hashable k) => TMapChan k a -> k -> TChan a -> STM ()
    setTChan (TMapChan t) k c = modifyTVar' t (HashMap.insert k c)
    
    
    broadcast :: (Eq k, Hashable k) => TMapChan k a -> a -> STM ()
    broadcast t@(TMapChan xs) a = do
      ks <- HashMap.keys <$> readTVar xs
    

    Found in Control.Concurrent.STM.TMapChan.Hash from the package tmapchan
    -- * Utils
    
    keys :: TMapChan k a -> STM [k]
    keys (TMapChan m) = HashMap.keys <$> readTVar m
    
    
    -- | Creates a new one if it doesn't already exist
    getTChan :: (Eq k, Hashable k) => TMapChan k a -> k -> STM (TChan a)
    getTChan (TMapChan t) k = do
      xs <- readTVar t
      case HashMap.lookup k xs of
        Nothing -> do
          c' <- newTChan
          writeTVar t (HashMap.insert k c' xs)
          pure c'
        Just c' -> pure c'
    
    setTChan :: (Eq k, Hashable k) => TMapChan k a -> k -> TChan a -> STM ()
    setTChan (TMapChan t) k c = modifyTVar' t (HashMap.insert k c)
    

    Found in Control.Concurrent.STM.TMapChan.Hash from the package tmapchan
    newtype TMapChan k a = TMapChan {runTMapChan :: TVar (HashMap k (TChan a))}
    
    
    newTMapChan :: STM (TMapChan k a)
    newTMapChan = TMapChan <$> newTVar HashMap.empty
    
    insert :: (Eq k, Hashable k) => TMapChan k a -> k -> a -> STM ()
    insert t k a = do
      c <- getTChan t k
      writeTChan c a
    
    insertMany :: (Eq k, Hashable k) => TMapChan k a -> k -> [a] -> STM ()
    insertMany t k as = forM_ as (insert t k)
    
    -- | Inserts the element to the head of the stack, to be viewed next
    insertFirst :: (Eq k, Hashable k) => TMapChan k a -> k -> a -> STM ()
    insertFirst t k a = do
      c <- getTChan t k
    

    Found in Control.Concurrent.STM.TMapChan.Hash from the package tmapchan
    import qualified Data.HashSet as HashSet
    import Control.Monad (void, forM_)
    import Control.Concurrent.STM (STM)
    import Control.Concurrent.STM.TChan (TChan, newTChan, writeTChan, readTChan, tryReadTChan, peekTChan, tryPeekTChan, unGetTChan)
    import Control.Concurrent.STM.TVar (TVar, newTVar, readTVar, writeTVar, modifyTVar')
    
    
    newtype TMapChan k a = TMapChan {runTMapChan :: TVar (HashMap k (TChan a))}
    
    
    newTMapChan :: STM (TMapChan k a)
    newTMapChan = TMapChan <$> newTVar HashMap.empty
    
    insert :: (Eq k, Hashable k) => TMapChan k a -> k -> a -> STM ()
    insert t k a = do
      c <- getTChan t k
      writeTChan c a
    
    insertMany :: (Eq k, Hashable k) => TMapChan k a -> k -> [a] -> STM ()
    insertMany t k as = forM_ as (insert t k)
    

    Found in Control.Concurrent.STM.TMapChan.Hash from the package tmapchan
    import qualified Data.HashMap.Strict as HashMap
    import qualified Data.HashSet as HashSet
    import Control.Monad (void, forM_)
    import Control.Concurrent.STM (STM)
    import Control.Concurrent.STM.TChan (TChan, newTChan, writeTChan, readTChan, tryReadTChan, peekTChan, tryPeekTChan, unGetTChan)
    import Control.Concurrent.STM.TVar (TVar, newTVar, readTVar, writeTVar, modifyTVar')
    
    
    newtype TMapChan k a = TMapChan {runTMapChan :: TVar (HashMap k (TChan a))}
    
    
    newTMapChan :: STM (TMapChan k a)
    newTMapChan = TMapChan <$> newTVar HashMap.empty
    
    insert :: (Eq k, Hashable k) => TMapChan k a -> k -> a -> STM ()
    insert t k a = do
      c <- getTChan t k
      writeTChan c a
    
    insertMany :: (Eq k, Hashable k) => TMapChan k a -> k -> [a] -> STM ()
    

    Found in Universum.Nub from the package universum
          then go s xs
          else x : go (Set.insert x s) xs
    
    -- | Like 'Prelude.nub' but runs in @O(n * log_16(n))@ time and requires 'Hashable'.
    --
    -- >>> hashNub [3, 3, 3, 2, 2, -1, 1]
    -- [3,2,-1,1]
    hashNub :: (Eq a, Hashable a) => [a] -> [a]
    hashNub = go HashSet.empty
      where
        go _ []     = []
        go s (x:xs) =
          if x `HashSet.member` s
          then go s xs
          else x : go (HashSet.insert x s) xs
    
    -- | Like 'ordNub' but also sorts a list.
    --
    -- >>> sortNub [3, 3, 3, 2, 2, -1, 1]
    -- [-1,1,2,3]
    

    Found in Universum.Nub from the package universum
    {-@ Set.toList :: Set a -> ListUnique a @-}
    
    -- | Like 'Prelude.nub' but runs in @O(n * log n)@ time and requires 'Ord'.
    --
    -- >>> ordNub [3, 3, 3, 2, 2, -1, 1]
    -- [3,2,-1,1]
    ordNub :: (Ord a) => [a] -> [a]
    ordNub = go Set.empty
      where
        go _ []     = []
        go s (x:xs) =
          if x `Set.member` s
          then go s xs
          else x : go (Set.insert x s) xs
    
    -- | Like 'Prelude.nub' but runs in @O(n * log_16(n))@ time and requires 'Hashable'.
    --
    -- >>> hashNub [3, 3, 3, 2, 2, -1, 1]
    -- [3,2,-1,1]
    

    intersection See 2 Occurences [+] Collapse [-]
    Found in Math.MFSolve from the package mfsolve
          -- 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
          -- 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
    

    Found in RIO.HashSet from the package rio
      , Data.HashSet.unions
    
      -- * Basic interface
      , Data.HashSet.null
      , Data.HashSet.size
      , Data.HashSet.member
      , Data.HashSet.insert
      , Data.HashSet.delete
    
      -- * Transformations
      , Data.HashSet.map
    
        -- * Difference and intersection
      , Data.HashSet.difference
      , Data.HashSet.intersection
    
      -- * Folds
      , Data.HashSet.foldl'
      , Data.HashSet.foldr
    

    map See 23 Occurences [+] Collapse [-]
    Found in Language.C.Inline.HaskellIdentifier from the package inline-c
    mangleHaskellIdentifier :: HaskellIdentifier -> C.CIdentifier
    mangleHaskellIdentifier (HaskellIdentifier hs) =
      -- The leading underscore if we have no valid chars is because then
      -- we'd have an identifier starting with numbers.
      let cs = (if null valid then "_" else "") ++
               valid ++
               (if null mangled || null valid then "" else "_") ++
               mangled
      in case C.cIdentifierFromString cs of
        Left err -> error $ "mangleHaskellIdentifier: produced bad C identifier\n" ++ err
        Right x -> x
      where
        (valid, invalid) = partition (`elem` C.cIdentLetter) hs
    
        mangled = concat $ intersperse "_" $ map (`showHex` "") $ map ord invalid
    
    -- Utils
    ------------------------------------------------------------------------
    
    identNoLex :: (TokenParsing m, Monad m, IsString s) => IdentifierStyle m -> m s
    

    Found in Language.C.Inline.HaskellIdentifier from the package inline-c
    mangleHaskellIdentifier :: HaskellIdentifier -> C.CIdentifier
    mangleHaskellIdentifier (HaskellIdentifier hs) =
      -- The leading underscore if we have no valid chars is because then
      -- we'd have an identifier starting with numbers.
      let cs = (if null valid then "_" else "") ++
               valid ++
               (if null mangled || null valid then "" else "_") ++
               mangled
      in case C.cIdentifierFromString cs of
        Left err -> error $ "mangleHaskellIdentifier: produced bad C identifier\n" ++ err
        Right x -> x
      where
        (valid, invalid) = partition (`elem` C.cIdentLetter) hs
    
        mangled = concat $ intersperse "_" $ map (`showHex` "") $ map ord invalid
    
    -- Utils
    ------------------------------------------------------------------------
    
    identNoLex :: (TokenParsing m, Monad m, IsString s) => IdentifierStyle m -> m s
    

    Found in Language.C.Types.Parse from the package inline-c
      [] -> ""
      [x] -> pretty x
      x : xs'@(_:_) -> pretty x <> "," <+> prettyParams xs'
    
    instance Pretty i => Pretty (ArrayType i) where
      pretty at = case at of
        VariablySized -> "*"
        SizedByInteger n -> pretty n
        SizedByIdentifier s -> pretty s
        Unsized -> ""
    
    instance Pretty i => Pretty (ParameterDeclaration i) where
      pretty (ParameterDeclaration declSpecs decltor) = case declSpecs of
        [] -> decltorDoc
        _:_ -> hsep (map pretty declSpecs) <+> decltorDoc
        where
          decltorDoc = case decltor of
            IsDeclarator x -> pretty x
            IsAbstractDeclarator x -> pretty x
    

    Found in Language.C.Types.Parse from the package inline-c
    instance Pretty FunctionSpecifier where
      pretty funSpec = case funSpec of
        INLINE -> "inline"
    
    instance Pretty i => Pretty (Declarator i) where
      pretty (Declarator ptrs ddecltor) = case ptrs of
        [] -> pretty ddecltor
        _:_ -> prettyPointers ptrs <+> pretty ddecltor
    
    prettyPointers :: [Pointer] -> Doc
    prettyPointers [] = ""
    prettyPointers (x : xs) = pretty x <> prettyPointers xs
    
    instance Pretty Pointer where
      pretty (Pointer tyQual) = "*" <> hsep (map pretty tyQual)
    
    instance Pretty i => Pretty (DirectDeclarator i) where
      pretty decltor = case decltor of
        DeclaratorRoot x -> pretty x
        DeclaratorParens x -> "(" <> pretty x <> ")"
    

    Found in Math.MFSolve from the package mfsolve
    -- it depends on.  Only linear dependencies are shown.
    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 ()
    

    Found in Math.MFSolve from the package mfsolve
    -- | Return the value of the variable, or a list of variables
    -- it depends on.  Only linear dependencies are shown.
    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`.
    

    Found in Math.MFSolve from the package mfsolve
    -- freeVars (Dependencies dep) =
    --   HS.toList $ M.foldl' addVars HS.empty dep
    --   where addVars s (LinExpr _ a) =
    --           HS.union s $ HS.fromList $ map fst a
    
    -- | Return the value of the variable, or a list of variables
    -- it depends on.  Only linear dependencies are shown.
    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 ++
    

    Found in Math.MFSolve from the package mfsolve
      | otherwise =
        ([], m)
    
    dmod :: RealFrac a => a -> a -> a
    dmod a b = abs((a/b) - fromInteger (round (a/b)) * b)
    
    -- put the variable with the maximum coefficient on the lhs of the
    -- equation
    splitMax :: (Ord b, Fractional b, Eq v) => LinExpr v b -> (v, b, LinExpr v b)
    splitMax (LinExpr c t) =
      let ((v,c2),r) = maximumBy (compare `on` (abs.snd.fst)) $
                       select t
      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
    

    Found in Math.MFSolve from the package mfsolve
           M.delete v m)
      -- the variable is independent in:
      -- v2 = e (== sin(p+const) + const*v + linear)
      -- rearrange, and substitute
      | Just (v2, e) <-
        find (hasVar v.snd) $ M.toList m =
          let e2 = reArrangeTrig v2 e v
              substOne (v3, c)
                | v == v3 = e2 * ConstE c
                | otherwise = makeVariable v3 * ConstE c
              doSubst (Expr (LinExpr c lt) trig _) =
                foldr ((+).substOne) 
                (ConstE c + trigExpr trig) lt
          in ([makeVariable v - e],
              M.map doSubst $ M.delete v2 m)
      -- variable not found
      | otherwise =
        ([], m)
    
    dmod :: RealFrac a => a -> a -> a
    

    Found in Math.MFSolve from the package mfsolve
                 Left _ -> (deps, e) --shouldn't happen
                 Right d -> (d, e)
      | otherwise =
          let (l, trig2') =
                M.foldrWithKey trigFold
                ([], M.empty) trig2
              trigFold p t (l2, m2) =
                let (l3, m1) = elimTrig p t v
                    mp | M.null m1 = m2
                       | otherwise = M.insert p m1 m2
                in (l3++l2, mp)
                
              (nlWith, nlWithout) =
                partition (hasVar v) $
                map trigToExpr trig ++ nonlin
              deps = Dependencies vdep lin [] trig2' []
          in case foldM (flip addEq0 zeroExpr) deps
                  nlWithout of
                 Left _ -> (deps, nlWith++l) --shouldn't happen
                 Right d -> (d, nlWith++l)
    

    Found in Math.MFSolve from the package mfsolve
           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 $
                     map (subst $ simpleSubst v lt2)
                     (trig'++trig2'++nonlin) of
                 Left _ -> (deps, e) --shouldn't happen
                 Right d -> (d, e)
      | otherwise =
          let (l, trig2') =
    

    Found in Math.MFSolve from the package mfsolve
        -- v is dependend, so doesn't appear in other equations
        (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)
    

    Found in Math.MFSolve from the package mfsolve
    addEq0 :: (Hashable v, Hashable n, RealFrac (Phase n), Ord v, Floating n) => Dependencies v n -> Expr v n -> Expr v n -> Either (DepError v n) (Dependencies v n)
    -- 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
    

    Found in Math.MFSolve from the package mfsolve
    noDeps = Dependencies M.empty M.empty [] M.empty []
    
    simpleSubst :: Eq a => a -> b -> a -> Maybe b
    simpleSubst x y z
      | x == z = Just y
      | otherwise = Nothing
    
    trigToExpr :: (Ord n, Ord v, Floating n) => TrigEq v n -> Expr v n
    trigToExpr (p, a, ph, c) =
      LinearE a * sin(LinearE $ LinExpr ph p) +
      ConstE c
    
    trig2ToExpr :: (Ord v, Floating n, Ord n) => M.HashMap v (Expr v n) -> [Expr v n]
    trig2ToExpr =
      map (\(v,e)-> makeVariable v-e)
      . M.toList
    
    addEqs :: (Hashable v, Hashable n, RealFrac (Phase n), Ord v, Floating n) => Dependencies v n -> [Expr v n] -> Either (DepError v n) (Dependencies v n)
    addEqs = foldM addEquation
    

    Found in Math.MFSolve from the package mfsolve
             Just expr -> mulLinExpr c expr
      in foldr (addLin.substOne) (LinExpr a []) terms
    
    substVarNonLin :: (Ord n, Ord v, Floating n) => (v -> Maybe (LinExpr v n)) -> NonLinExpr v n -> Expr v n
    substVarNonLin s (UnaryApp f e1) =
      unExpr f (subst s e1)
    substVarNonLin s (MulExp e1 e2) =
      subst s e1 * subst s e2
    substVarNonLin s (SinExp e1) =
      sin (subst s e1)
    
    substVarTrig :: (Ord v, Ord n, Floating n) => (v -> Maybe (LinExpr v n)) -> ([(v, n)], [(n, LinExpr v n)]) -> Expr v n
    substVarTrig s (period, terms) =
      let period2 = LinearE $ substVarLin s (LinExpr 0 period)
          terms2 = map (fmap $ LinearE . substVarLin s) terms
      in foldr (\(p,a) -> (+ (a * sin (ConstE p + period2))))
         0 terms2
    
    subst :: (Ord n, Ord v, Floating n) => (v -> Maybe (LinExpr v n)) -> Expr v n -> Expr v n
    subst s (Expr lt trig nl) =
    

    Found in Math.MFSolve from the package mfsolve
          trigExpr [(theta, [(alpha, mulLinExpr c lt)])]
        -- linear amplitude
        mul1 t =
          nonlinExpr [MulExp (trigExpr [(theta, [t])])
                      (Expr lt [] [])]
    
    -- constant * (linear + trig)
    mulExpr :: (Ord a, Ord t, Floating a) => Expr t a -> Expr t a -> Expr t a
    mulExpr (ConstE c) (Expr lt2 trig []) =
      Expr (mulLinExpr c lt2)
      (map (mulConstTrig c) trig) []
    
    mulExpr (Expr lt2 trig []) (ConstE c) =
      Expr (mulLinExpr c lt2)
      (map (mulConstTrig c) trig) []
    
    -- linear * (constant + trig)
    mulExpr (LinearE lt) (Expr (LConst c) trig []) =
      LinearE (mulLinExpr c lt) +
      foldr ((+).mulLinTrig lt) 0 trig
    

    Found in Math.MFSolve from the package mfsolve
      foldr ((+).mul1) 0 terms
      where
        -- constant amplitude
        mul1 (alpha, LinExpr c []) =
          trigExpr [(theta, [(alpha, mulLinExpr c lt)])]
        -- linear amplitude
        mul1 t =
          nonlinExpr [MulExp (trigExpr [(theta, [t])])
                      (Expr lt [] [])]
    
    -- constant * (linear + trig)
    mulExpr :: (Ord a, Ord t, Floating a) => Expr t a -> Expr t a -> Expr t a
    mulExpr (ConstE c) (Expr lt2 trig []) =
      Expr (mulLinExpr c lt2)
      (map (mulConstTrig c) trig) []
    
    mulExpr (Expr lt2 trig []) (ConstE c) =
      Expr (mulLinExpr c lt2)
      (map (mulConstTrig c) trig) []
    

    Found in Math.MFSolve from the package mfsolve
    compareBy [] [] _ = True
    compareBy (e:l) (e2:l2) f =
      f e e2 && compareBy l l2 f
    compareBy _ _ _ = False
            
    -- multiply a linear term by a constant.
    mulLinExpr :: Num n => n -> LinExpr v n -> LinExpr v n
    mulLinExpr x (LinExpr e terms) =
      LinExpr (e*x) $ map (fmap (*x)) terms
    
    -- multiply all sines with the constant
    -- constant multiplier
    mulConstTrig :: (Ord n, Num n) => n -> TrigTerm v n -> TrigTerm v n
    mulConstTrig c (theta, terms) =  (theta, tt) where
      tt = map (fmap (mulLinExpr c)) terms
    
    mulLinTrig :: (Ord n, Ord v, Floating n) => LinExpr v n -> TrigTerm v n -> Expr v n
    mulLinTrig lt (theta, terms) =
      -- linear multiplier
      foldr ((+).mul1) 0 terms
    

    Found in Math.MFSolve from the package mfsolve
    compareTerm :: (Ord a1, Fractional a1, Eq a) => a1 -> (a, a1) -> (a, a1) -> Bool
    compareTerm ratio (v3,c3) (v4, c4) = 
      v3 == v4 && (abs(c3 - (c4 * ratio)) <= abs c3*2e-50)
    
    compareBy :: [a] -> [b] -> (a -> b -> Bool) -> Bool
    compareBy [] [] _ = True
    compareBy (e:l) (e2:l2) f =
      f e e2 && compareBy l l2 f
    compareBy _ _ _ = False
            
    -- multiply a linear term by a constant.
    mulLinExpr :: Num n => n -> LinExpr v n -> LinExpr v n
    mulLinExpr x (LinExpr e terms) =
      LinExpr (e*x) $ map (fmap (*x)) terms
    
    -- multiply all sines with the constant
    -- constant multiplier
    mulConstTrig :: (Ord n, Num n) => n -> TrigTerm v n -> TrigTerm v n
    mulConstTrig c (theta, terms) =  (theta, tt) where
    

    Found in Math.MFSolve from the package mfsolve
    makeVariable :: Num n => v -> Expr v n
    makeVariable v = LinearE $ LinExpr 0 [(v, 1)]
    
    trigExpr :: (Num n) => [TrigTerm v n] -> Expr v n
    trigExpr t = Expr zeroTerm t []
    
    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) $
    

    Found in Math.MFSolve from the package mfsolve
      cosh = unExpr Cosh
      atanh = unExpr Atanh
      tan = unExpr Tan
      tanh = unExpr Tanh
      sinh = unExpr Sinh
      asin = unExpr Asin
      acos = unExpr Acos
      asinh = unExpr Asinh
      acosh = unExpr Acosh
      atan = unExpr Atan
    
    instance (Show n, Floating n, Ord n, Ord v, Show v) =>Show (Dependencies v n) where
      show dep@(Dependencies _ lin _ _ _) = 
        unlines (map showLin (M.toList lin) ++
                 map showNl (nonlinearEqs dep))
        where showLin (v, e) = show v ++ " = " ++ show (LinearE e)
              showNl e = show e ++ " = 0"
    
    instance (Num n, Ord n, Show n, Show v) => Show (DepError v n) where
      show (InconsistentEq a e) =
    

    Found in Math.MFSolve from the package mfsolve
      cos a = sinExpr (a + ConstE (pi/2))
      cosh = unExpr Cosh
      atanh = unExpr Atanh
      tan = unExpr Tan
      tanh = unExpr Tanh
      sinh = unExpr Sinh
      asin = unExpr Asin
      acos = unExpr Acos
      asinh = unExpr Asinh
      acosh = unExpr Acosh
      atan = unExpr Atan
    
    instance (Show n, Floating n, Ord n, Ord v, Show v) =>Show (Dependencies v n) where
      show dep@(Dependencies _ lin _ _ _) = 
        unlines (map showLin (M.toList lin) ++
                 map showNl (nonlinearEqs dep))
        where showLin (v, e) = show v ++ " = " ++ show (LinearE e)
              showNl e = show e ++ " = 0"
    
    instance (Num n, Ord n, Show n, Show v) => Show (DepError v n) where
    

    Found in RIO.HashSet from the package rio
      , Data.HashSet.singleton
    
      -- * Combine
      , Data.HashSet.union
      , Data.HashSet.unions
    
      -- * Basic interface
      , Data.HashSet.null
      , Data.HashSet.size
      , Data.HashSet.member
      , Data.HashSet.insert
      , Data.HashSet.delete
    
      -- * Transformations
      , Data.HashSet.map
    
        -- * Difference and intersection
      , Data.HashSet.difference
      , Data.HashSet.intersection
    

    member See 47 Occurences [+] Collapse [-]
    Found in Database.Beam.Migrate.Actions from the package beam-migrate
        heuristicSolver' !q !visited !bestRejected =
          case PQ.minView q of
            Nothing -> SearchFailed (measuredDbState <$> PQ.toList bestRejected)
            Just (mdbState@(MeasuredDatabaseState _ _ dbState), q')
              | dbStateKey dbState `HS.member` visited -> heuristicSolver' q' visited bestRejected
              | solvedState postConditions (measuredDbState mdbState) ->
                  ProvideSolution (toList (dbStateCmdSequence dbState))
              | otherwise ->
                  let steps = getPotentialActions
                                  provider
                                  (findPredicates (dbStateKey dbState))
                                  (findPredicates postConditionsL)
    
                      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') =
    

    Found in Database.Beam.Migrate.Actions from the package beam-migrate
          | 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')
              | dbStateKey dbState `HS.member` visited -> heuristicSolver' q' visited bestRejected
              | solvedState postConditions (measuredDbState mdbState) ->
                  ProvideSolution (toList (dbStateCmdSequence dbState))
              | otherwise ->
                  let steps = getPotentialActions
                                  provider
    

    Found in Control.Foldl from the package foldl
    list = Fold (\x a -> x . (a:)) id ($ [])
    {-# INLINABLE list #-}
    
    -- | Fold all values into a list, in reverse order
    revList :: Fold a [a]
    revList = Fold (\x a -> a:x) [] id
    {-# INLINABLE revList #-}
    
    {-| /O(n log n)/.  Fold values into a list with duplicates removed, while
        preserving their first occurrences
    -}
    nub :: Ord a => Fold a [a]
    nub = Fold step (Pair Set.empty id) fin
      where
        step (Pair s r) a = if Set.member a s
          then Pair s r
          else Pair (Set.insert a s) (r . (a :))
        fin (Pair _ r) = r []
    {-# INLINABLE nub #-}
    

    Found in Data.Core.Graph.PureCore from the package graph-core
    -- FIXME: benchmark against old hullFold implementation
    hullFold :: Graph -> (b -> Node -> b) -> b -> Node -> b
    hullFold g f initial node =
        runIdentity $ hullFoldImpl (g_adj g) (\x y -> return (f x y)) initial node
    
    hullFoldM :: Monad m => Graph -> (b -> Node -> m b) -> b -> Node -> m b
    hullFoldM g = hullFoldImpl (g_adj g)
    
    hullFoldImpl :: Monad m => AdjList -> (b -> Node -> m b) -> b -> Node -> m b
    hullFoldImpl adj f initial root =
        go IS.empty initial [root]
        where
          go _ acc [] = return acc
          go !visited !acc (x:xs) =
              if (IS.member x visited)
              then go visited acc xs
              else do newAcc <- f acc x
                      let succs = IM.findWithDefault VU.empty x adj
                      go (IS.insert x visited) newAcc (xs ++ VU.toList succs)
    

    Found in Data.Core.Graph.PureCore from the package graph-core
    removeEdges :: [Edge] -> Graph -> Graph
    removeEdges edgeList g = L.foldl' (flip (\(Edge x y) -> removeEdge x y)) g edgeList
    
    hull :: Graph -> Node -> NodeSet
    hull g = hullImpl g (g_adj g)
    
    rhull :: Graph -> Node -> NodeSet
    rhull g = hullImpl g (g_radj g)
    
    hullImpl :: Graph -> AdjList -> Node -> NodeSet
    hullImpl (Graph{..}) adj root =
        runST $
           do vis <- newSTRef IS.empty
              let go x =
                   (IS.member x <$> readSTRef vis) >>=
                      (flip unless $
                         do modifySTRef' vis (IS.insert x)
                            VU.forM_ (IM.findWithDefault VU.empty x adj) go)
              go root
              readSTRef vis
    

    Found in Language.C.Inline.HaskellIdentifier from the package inline-c
        Left err -> error $ "mangleHaskellIdentifier: produced bad C identifier\n" ++ err
        Right x -> x
      where
        (valid, invalid) = partition (`elem` C.cIdentLetter) hs
    
        mangled = concat $ intersperse "_" $ map (`showHex` "") $ map ord invalid
    
    -- Utils
    ------------------------------------------------------------------------
    
    identNoLex :: (TokenParsing m, Monad m, IsString s) => IdentifierStyle m -> m s
    identNoLex s = fmap fromString $ try $ do
      name <- highlight (_styleHighlight s)
              ((:) <$> _styleStart s <*> many (_styleLetter s) <?> _styleName s)
      when (HashSet.member name (_styleReserved s)) $ unexpected $ "reserved " ++ _styleName s ++ " " ++ show name
      return name
    

    Found in Language.C.Types.Parse from the package inline-c
    -- void yyerror(char const *s)
    -- {
    -- 	fflush(stdout);
    -- 	printf("\n%*s\n%*s\n", column, "^", column, s);
    -- }
    -- @
    
    -- Utils
    ------------------------------------------------------------------------
    
    identNoLex :: (TokenParsing m, Monad m, IsString s) => IdentifierStyle m -> m s
    identNoLex s = fmap fromString $ try $ do
      name <- highlight (_styleHighlight s)
              ((:) <$> _styleStart s <*> many (_styleLetter s) <?> _styleName s)
      when (HashSet.member name (_styleReserved s)) $ unexpected $ "reserved " ++ _styleName s ++ " " ++ show name
      return name
    

    Found in Language.C.Types.Parse from the package inline-c
    cidentifier_no_lex = try $ do
      s <- cidentifier_raw
      typeNames <- asks cpcTypeNames
      when (HashSet.member s typeNames) $
        unexpected $ "type name " ++ unCIdentifier s
      return s
    
    cidentifier :: CParser i m => m CIdentifier
    cidentifier = token cidentifier_no_lex
    
    type_name :: CParser i m => m CIdentifier
    type_name = try $ do
      s <- ident cIdentStyle <?> "type name"
      typeNames <- asks cpcTypeNames
      unless (HashSet.member s typeNames) $
        unexpected $ "identifier  " ++ unCIdentifier s
      return s
    
    data TypeQualifier
      = CONST
    

    Found in Language.C.Types.Parse from the package inline-c
        unexpected $ "type name " ++ cpcIdentToString ctx id_
      return id_
    
    -- | Same as 'cidentifier_no_lex', but does not check that the
    -- identifier is not a type name.
    cidentifier_raw :: (TokenParsing m, Monad m) => m CIdentifier
    cidentifier_raw = identNoLex cIdentStyle
    
    -- | This parser parses a 'CIdentifier' and nothing else -- it does not consume
    -- trailing spaces and the like.
    cidentifier_no_lex :: CParser i m => m CIdentifier
    cidentifier_no_lex = try $ do
      s <- cidentifier_raw
      typeNames <- asks cpcTypeNames
      when (HashSet.member s typeNames) $
        unexpected $ "type name " ++ unCIdentifier s
      return s
    
    cidentifier :: CParser i m => m CIdentifier
    cidentifier = token cidentifier_no_lex
    

    Found in Language.C.Types.Parse from the package inline-c
      , UNSIGNED <$ reserve cIdentStyle "unsigned"
      , Struct <$> (reserve cIdentStyle "struct" >> cidentifier)
      , Enum <$> (reserve cIdentStyle "enum" >> cidentifier)
      , TypeName <$> type_name
      ]
    
    identifier :: CParser i m => m i
    identifier = token identifier_no_lex
    
    isTypeName :: TypeNames -> String -> Bool
    isTypeName typeNames id_ =
      case cIdentifierFromString id_ of
        -- If it's not a valid C identifier, then it's definitely not a C type name.
        Left _err -> False
        Right s -> HashSet.member s typeNames
    
    identifier_no_lex :: CParser i m => m i
    identifier_no_lex = try $ do
      ctx <- ask
      id_ <- cpcParseIdent ctx <?> cpcIdentName ctx
    

    Found in Text.Html.IsLink from the package islink
        -- * Example with HXT
        -- $example
        ) where
    
    import Data.HashSet (HashSet)
    import qualified Data.HashSet as HS
    
    -- | @isLinkAttr tag attr@ returns 'True' if the attribute @attr@ of an HTML
    -- element with tag name @tag@ points to an external resource, and 'False'
    -- otherwise. So for example @isLinkAttr \"a\" \"href\"@ returns 'True' whereas
    -- @isLinkAttr \"a\" \"class\"@ returns 'False'. Note that 'isLinkAttr'
    -- expects both @tag@ and @attr@ to be in lowercase, so for example
    -- @isLinkAttr \"A\" \"HREF\"@ returns 'False'.
    isLinkAttr :: String -> String -> Bool
    isLinkAttr tag attr = HS.member (tag, attr) allLinkAttrs
    
    -- sources:
    --     * The HTML 4.01 transitional DTD
    --     * The HTML 4.01 strict DTD
    --     * The HTML 3.2 DTD
    

    Found in LLVM.IRBuilder.Monad from the package llvm-hs-pure
    -- | Generate a fresh name. The resulting name is numbered or
    -- based on the name suggested with 'named' if that's used.
    fresh :: MonadIRBuilder m => m Name
    fresh = do
      msuggestion <- liftIRState $ gets builderNameSuggestion
      maybe freshUnName freshName msuggestion
    
    -- | Generate a fresh name from a name suggestion
    freshName :: MonadIRBuilder m => ShortByteString -> m Name
    freshName suggestion = do
      usedNames <- liftIRState $ gets builderUsedNames
      let
        candidates = suggestion : [suggestion <> fromString (show n) | n <- [(1 :: Int)..]]
        (unusedName:_) = filter (not . (`HS.member` usedNames)) candidates
      liftIRState $ modify $ \s -> s { builderUsedNames = HS.insert unusedName $ builderUsedNames s }
      return $ Name unusedName
    
    -- | Generate a fresh numbered name
    freshUnName :: MonadIRBuilder m => m Name
    

    Found in Text.Parser.Token from the package parsers
    {-# INLINE reserve #-}
    
    -- | parse a reserved operator or identifier using a given style given 'Text'.
    reserveText :: (TokenParsing m, Monad m) => IdentifierStyle m -> Text -> m ()
    reserveText s name = token $ try $ do
       _ <- highlight (_styleReservedHighlight s) $ text name
       notFollowedBy (_styleLetter s) <?> "end of " ++ show name
    {-# INLINE reserveText #-}
    
    -- | Parse a non-reserved identifier or symbol
    ident :: (TokenParsing m, Monad m, IsString s) => IdentifierStyle m -> m s
    ident s = fmap fromString $ token $ try $ do
      name <- highlight (_styleHighlight s)
              ((:) <$> _styleStart s <*> many (_styleLetter s) <?> _styleName s)
      when (HashSet.member name (_styleReserved s)) $ unexpected $ "reserved " ++ _styleName s ++ " " ++ show name
      return name
    {-# INLINE ident #-}
    
    -- * Utilities
    

    Found in Relude.Nub from the package relude
          then go s xs
          else x : go (Set.insert x s) xs
    
    {- | Like 'Prelude.nub' but runs in @O(n * log_16(n))@ time and requires 'Hashable'.
    
    >>> hashNub [3, 3, 3, 2, 2, -1, 1]
    [3,2,-1,1]
    
    -}
    hashNub :: (Eq a, Hashable a) => [a] -> [a]
    hashNub = go HashSet.empty
      where
        go _ []     = []
        go s (x:xs) =
          if x `HashSet.member` s
          then go s xs
          else x : go (HashSet.insert x s) xs
    
    {- | Like 'ordNub' but also sorts a list.
    

    Found in Relude.Nub from the package relude
    import qualified Data.Set as Set
    
    {- | Like 'Prelude.nub' but runs in @O(n * log n)@ time and requires 'Ord'.
    
    >>> ordNub [3, 3, 3, 2, 2, -1, 1]
    [3,2,-1,1]
    
    -}
    ordNub :: (Ord a) => [a] -> [a]
    ordNub = go Set.empty
      where
        go _ []     = []
        go s (x:xs) =
          if x `Set.member` s
          then go s xs
          else x : go (Set.insert x s) xs
    
    {- | Like 'Prelude.nub' but runs in @O(n * log_16(n))@ time and requires 'Hashable'.
    

    Found in Relude.Extra.Map from the package relude
        member = IS.member
        lookup k m = guard (member k m) *> pure k
        {-# INLINE size #-}
        {-# INLINE lookup #-}
        {-# INLINE member #-}
    
    -- | Operator version of 'lookup' function.
    infixl 9 !?
    (!?) :: StaticMap t => t -> Key t -> Maybe (Val t)
    (!?) m k = lookup k m
    {-# INLINE (!?) #-}
    
    -- | Inverse of 'member' function.
    notMember :: StaticMap t => Key t -> t -> Bool
    notMember k = not . member k
    {-# INLINE notMember #-}
    
    {- | Return the value to which the specified key is mapped, or the default value
    if this map contains no mapping for the key.
    -}
    

    Found in Relude.Extra.Map from the package relude
        lookup k m = guard (member k m) *> pure k
        {-# INLINE size #-}
        {-# INLINE lookup #-}
        {-# INLINE member #-}
    
    instance StaticMap IntSet where
        type Key IntSet = Int
        type Val IntSet = Int
    
        size   = IS.size
        member = IS.member
        lookup k m = guard (member k m) *> pure k
        {-# INLINE size #-}
        {-# INLINE lookup #-}
        {-# INLINE member #-}
    
    -- | Operator version of 'lookup' function.
    infixl 9 !?
    (!?) :: StaticMap t => t -> Key t -> Maybe (Val t)
    (!?) m k = lookup k m
    

    Found in Relude.Extra.Map from the package relude
        size   = HS.size
        member = HS.member
        lookup k m = guard (member k m) *> pure k
        {-# INLINE size #-}
        {-# INLINE lookup #-}
        {-# INLINE member #-}
    
    instance StaticMap IntSet where
        type Key IntSet = Int
        type Val IntSet = Int
    
        size   = IS.size
        member = IS.member
        lookup k m = guard (member k m) *> pure k
        {-# INLINE size #-}
        {-# INLINE lookup #-}
        {-# INLINE member #-}
    
    -- | Operator version of 'lookup' function.
    

    Found in Relude.Extra.Map from the package relude
        type Val (HashSet a) = a
    
        size   = HS.size
        member = HS.member
        lookup k m = guard (member k m) *> pure k
        {-# INLINE size #-}
        {-# INLINE lookup #-}
        {-# INLINE member #-}
    
    instance StaticMap IntSet where
        type Key IntSet = Int
        type Val IntSet = Int
    
        size   = IS.size
        member = IS.member
        lookup k m = guard (member k m) *> pure k
        {-# INLINE size #-}
        {-# INLINE lookup #-}
        {-# INLINE member #-}
    

    Found in Relude.Extra.Map from the package relude
        type Val (HashSet a) = a
    
        size   = HS.size
        member = HS.member
        lookup k m = guard (member k m) *> pure k
        {-# INLINE size #-}
        {-# INLINE lookup #-}
        {-# INLINE member #-}
    
    instance StaticMap IntSet where
        type Key IntSet = Int
        type Val IntSet = Int
    
        size   = IS.size
        member = IS.member
        lookup k m = guard (member k m) *> pure k
        {-# INLINE size #-}
        {-# INLINE lookup #-}
        {-# INLINE member #-}
    

    Found in Relude.Extra.Map from the package relude
        lookup k m = guard (member k m) *> pure k
        {-# INLINE size #-}
        {-# INLINE lookup #-}
        {-# INLINE member #-}
    
    instance (Eq a, Hashable a) => StaticMap (HashSet a) where
        type Key (HashSet a) = a
        type Val (HashSet a) = a
    
        size   = HS.size
        member = HS.member
        lookup k m = guard (member k m) *> pure k
        {-# INLINE size #-}
        {-# INLINE lookup #-}
        {-# INLINE member #-}
    
    instance StaticMap IntSet where
        type Key IntSet = Int
        type Val IntSet = Int
    

    Found in Relude.Extra.Map from the package relude
        size   = S.size
        member = S.member
        lookup k m = guard (member k m) *> pure k
        {-# INLINE size #-}
        {-# INLINE lookup #-}
        {-# INLINE member #-}
    
    instance (Eq a, Hashable a) => StaticMap (HashSet a) where
        type Key (HashSet a) = a
        type Val (HashSet a) = a
    
        size   = HS.size
        member = HS.member
        lookup k m = guard (member k m) *> pure k
        {-# INLINE size #-}
        {-# INLINE lookup #-}
        {-# INLINE member #-}
    
    instance StaticMap IntSet where
    

    Found in Relude.Extra.Map from the package relude
        type Val (Set a) = a
    
        size   = S.size
        member = S.member
        lookup k m = guard (member k m) *> pure k
        {-# INLINE size #-}
        {-# INLINE lookup #-}
        {-# INLINE member #-}
    
    instance (Eq a, Hashable a) => StaticMap (HashSet a) where
        type Key (HashSet a) = a
        type Val (HashSet a) = a
    
        size   = HS.size
        member = HS.member
        lookup k m = guard (member k m) *> pure k
        {-# INLINE size #-}
        {-# INLINE lookup #-}
        {-# INLINE member #-}
    

    Found in Relude.Extra.Map from the package relude
        type Val (Set a) = a
    
        size   = S.size
        member = S.member
        lookup k m = guard (member k m) *> pure k
        {-# INLINE size #-}
        {-# INLINE lookup #-}
        {-# INLINE member #-}
    
    instance (Eq a, Hashable a) => StaticMap (HashSet a) where
        type Key (HashSet a) = a
        type Val (HashSet a) = a
    
        size   = HS.size
        member = HS.member
        lookup k m = guard (member k m) *> pure k
        {-# INLINE size #-}
        {-# INLINE lookup #-}
        {-# INLINE member #-}
    

    Found in Relude.Extra.Map from the package relude
        member = IM.member
        {-# INLINE size #-}
        {-# INLINE lookup #-}
        {-# INLINE member #-}
    
    instance Ord a => StaticMap (Set a) where
        type Key (Set a) = a
        type Val (Set a) = a
    
        size   = S.size
        member = S.member
        lookup k m = guard (member k m) *> pure k
        {-# INLINE size #-}
        {-# INLINE lookup #-}
        {-# INLINE member #-}
    
    instance (Eq a, Hashable a) => StaticMap (HashSet a) where
        type Key (HashSet a) = a
        type Val (HashSet a) = a
    

    Found in Relude.Extra.Map from the package relude
        size   = IM.size
        lookup = IM.lookup
        member = IM.member
        {-# INLINE size #-}
        {-# INLINE lookup #-}
        {-# INLINE member #-}
    
    instance Ord a => StaticMap (Set a) where
        type Key (Set a) = a
        type Val (Set a) = a
    
        size   = S.size
        member = S.member
        lookup k m = guard (member k m) *> pure k
        {-# INLINE size #-}
        {-# INLINE lookup #-}
        {-# INLINE member #-}
    
    instance (Eq a, Hashable a) => StaticMap (HashSet a) where
    

    Found in Relude.Extra.Map from the package relude
        type Val (IntMap v) = v
    
        size   = IM.size
        lookup = IM.lookup
        member = IM.member
        {-# INLINE size #-}
        {-# INLINE lookup #-}
        {-# INLINE member #-}
    
    instance Ord a => StaticMap (Set a) where
        type Key (Set a) = a
        type Val (Set a) = a
    
        size   = S.size
        member = S.member
        lookup k m = guard (member k m) *> pure k
        {-# INLINE size #-}
        {-# INLINE lookup #-}
        {-# INLINE member #-}
    

    Found in Relude.Extra.Map from the package relude
        type Val (IntMap v) = v
    
        size   = IM.size
        lookup = IM.lookup
        member = IM.member
        {-# INLINE size #-}
        {-# INLINE lookup #-}
        {-# INLINE member #-}
    
    instance Ord a => StaticMap (Set a) where
        type Key (Set a) = a
        type Val (Set a) = a
    
        size   = S.size
        member = S.member
        lookup k m = guard (member k m) *> pure k
        {-# INLINE size #-}
        {-# INLINE lookup #-}
        {-# INLINE member #-}
    

    Found in Relude.Extra.Map from the package relude
        member = HM.member
        {-# INLINE size #-}
        {-# INLINE lookup #-}
        {-# INLINE member #-}
    
    instance StaticMap (IntMap v) where
        type Key (IntMap v) = Int
        type Val (IntMap v) = v
    
        size   = IM.size
        lookup = IM.lookup
        member = IM.member
        {-# INLINE size #-}
        {-# INLINE lookup #-}
        {-# INLINE member #-}
    
    instance Ord a => StaticMap (Set a) where
        type Key (Set a) = a
        type Val (Set a) = a
    

    Found in Relude.Extra.Map from the package relude
        size   = HM.size
        lookup = HM.lookup
        member = HM.member
        {-# INLINE size #-}
        {-# INLINE lookup #-}
        {-# INLINE member #-}
    
    instance StaticMap (IntMap v) where
        type Key (IntMap v) = Int
        type Val (IntMap v) = v
    
        size   = IM.size
        lookup = IM.lookup
        member = IM.member
        {-# INLINE size #-}
        {-# INLINE lookup #-}
        {-# INLINE member #-}
    
    instance Ord a => StaticMap (Set a) where
    

    Found in Relude.Extra.Map from the package relude
        size   = HM.size
        lookup = HM.lookup
        member = HM.member
        {-# INLINE size #-}
        {-# INLINE lookup #-}
        {-# INLINE member #-}
    
    instance StaticMap (IntMap v) where
        type Key (IntMap v) = Int
        type Val (IntMap v) = v
    
        size   = IM.size
        lookup = IM.lookup
        member = IM.member
        {-# INLINE size #-}
        {-# INLINE lookup #-}
        {-# INLINE member #-}
    
    instance Ord a => StaticMap (Set a) where
    

    Found in Relude.Extra.Map from the package relude
        member = M.member
        {-# INLINE size #-}
        {-# INLINE lookup #-}
        {-# INLINE member #-}
    
    instance (Eq k, Hashable k) => StaticMap (HashMap k v) where
        type Key (HashMap k v) = k
        type Val (HashMap k v) = v
    
        size   = HM.size
        lookup = HM.lookup
        member = HM.member
        {-# INLINE size #-}
        {-# INLINE lookup #-}
        {-# INLINE member #-}
    
    instance StaticMap (IntMap v) where
        type Key (IntMap v) = Int
        type Val (IntMap v) = v
    

    Found in Relude.Extra.Map from the package relude
        size   = M.size
        lookup = M.lookup
        member = M.member
        {-# INLINE size #-}
        {-# INLINE lookup #-}
        {-# INLINE member #-}
    
    instance (Eq k, Hashable k) => StaticMap (HashMap k v) where
        type Key (HashMap k v) = k
        type Val (HashMap k v) = v
    
        size   = HM.size
        lookup = HM.lookup
        member = HM.member
        {-# INLINE size #-}
        {-# INLINE lookup #-}
        {-# INLINE member #-}
    
    instance StaticMap (IntMap v) where
    

    Found in Relude.Extra.Map from the package relude
        size   = M.size
        lookup = M.lookup
        member = M.member
        {-# INLINE size #-}
        {-# INLINE lookup #-}
        {-# INLINE member #-}
    
    instance (Eq k, Hashable k) => StaticMap (HashMap k v) where
        type Key (HashMap k v) = k
        type Val (HashMap k v) = v
    
        size   = HM.size
        lookup = HM.lookup
        member = HM.member
        {-# INLINE size #-}
        {-# INLINE lookup #-}
        {-# INLINE member #-}
    
    instance StaticMap (IntMap v) where
    

    Found in Relude.Extra.Map from the package relude
        size   :: t -> Int
        lookup :: Key t -> t -> Maybe (Val t)
        member :: Key t -> t -> Bool
    
    instance Ord k => StaticMap (Map k v) where
        type Key (Map k v) = k
        type Val (Map k v) = v
    
        size   = M.size
        lookup = M.lookup
        member = M.member
        {-# INLINE size #-}
        {-# INLINE lookup #-}
        {-# INLINE member #-}
    
    instance (Eq k, Hashable k) => StaticMap (HashMap k v) where
        type Key (HashMap k v) = k
        type Val (HashMap k v) = v
    

    Found in Relude.Extra.Map from the package relude
    class StaticMap t where
        type Key t :: Type
        type Val t :: Type
    
        size   :: t -> Int
        lookup :: Key t -> t -> Maybe (Val t)
        member :: Key t -> t -> Bool
    
    instance Ord k => StaticMap (Map k v) where
        type Key (Map k v) = k
        type Val (Map k v) = v
    
        size   = M.size
        lookup = M.lookup
        member = M.member
        {-# INLINE size #-}
        {-# INLINE lookup #-}
        {-# INLINE member #-}
    
    instance (Eq k, Hashable k) => StaticMap (HashMap k v) where
    

    Found in Relude.Extra.Map from the package relude
    class StaticMap t where
        type Key t :: Type
        type Val t :: Type
    
        size   :: t -> Int
        lookup :: Key t -> t -> Maybe (Val t)
        member :: Key t -> t -> Bool
    
    instance Ord k => StaticMap (Map k v) where
        type Key (Map k v) = k
        type Val (Map k v) = v
    
        size   = M.size
        lookup = M.lookup
        member = M.member
        {-# INLINE size #-}
        {-# INLINE lookup #-}
        {-# INLINE member #-}
    
    instance (Eq k, Hashable k) => StaticMap (HashMap k v) where
    

    Found in Relude.Extra.Map from the package relude
    ----------------------------------------------------------------------------
    -- Static Map
    ----------------------------------------------------------------------------
    
    {- | Read-only map or set. Contains polymorhic functions which work for both
    sets and maps.
    -}
    class StaticMap t where
        type Key t :: Type
        type Val t :: Type
    
        size   :: t -> Int
        lookup :: Key t -> t -> Maybe (Val t)
        member :: Key t -> t -> Bool
    
    instance Ord k => StaticMap (Map k v) where
        type Key (Map k v) = k
        type Val (Map k v) = v
    

    Found in RIO.HashSet from the package rio
      (
        Data.HashSet.HashSet
    
      -- * Construction
      , Data.HashSet.empty
      , Data.HashSet.singleton
    
      -- * Combine
      , Data.HashSet.union
      , Data.HashSet.unions
    
      -- * Basic interface
      , Data.HashSet.null
      , Data.HashSet.size
      , Data.HashSet.member
      , Data.HashSet.insert
      , Data.HashSet.delete
    
      -- * Transformations
      , Data.HashSet.map
    

    Found in Data.Swagger.Internal.Schema from the package swagger2
          fieldSchema  = gdeclareNamedSchema opts (Proxy :: Proxy f) s
    
    gdeclareSchemaRef :: GToSchema a => SchemaOptions -> proxy a -> Declare (Definitions Schema) (Referenced Schema)
    gdeclareSchemaRef opts proxy = do
      case gtoNamedSchema opts proxy of
        NamedSchema (Just name) schema -> do
          -- This check is very important as it allows generically
          -- derive used definitions for recursive schemas.
          -- Lazy Declare monad allows toNamedSchema to ignore
          -- any declarations (which would otherwise loop) and
          -- retrieve the schema and its name to check if we
          -- have already declared it.
          -- If we have, we don't need to declare anything for
          -- this schema this time and thus simply return the reference.
          known <- looks (InsOrdHashMap.member name)
          when (not known) $ do
            declare [(name, schema)]
            void $ gdeclareNamedSchema opts proxy mempty
          return $ Ref (Reference name)
        _ -> Inline <$> gdeclareSchema opts proxy
    

    Found in Data.Swagger.Internal.Schema from the package swagger2
    -- If @'declareSchemaRef'@ returns a reference, a corresponding schema
    -- will be declared (regardless of whether it is recusive or not).
    declareSchemaRef :: ToSchema a => proxy a -> Declare (Definitions Schema) (Referenced Schema)
    declareSchemaRef proxy = do
      case toNamedSchema proxy of
        NamedSchema (Just name) schema -> do
          -- This check is very important as it allows generically
          -- derive used definitions for recursive schemas.
          -- Lazy Declare monad allows toNamedSchema to ignore
          -- any declarations (which would otherwise loop) and
          -- retrieve the schema and its name to check if we
          -- have already declared it.
          -- If we have, we don't need to declare anything for
          -- this schema this time and thus simply return the reference.
          known <- looks (InsOrdHashMap.member name)
          when (not known) $ do
            declare [(name, schema)]
            void $ declareNamedSchema proxy
          return $ Ref (Reference name)
        _ -> Inline <$> declareSchema proxy
    

    Found in Data.Swagger.Internal.Schema.Validation from the package swagger2
            when (size > n) $
              invalid ("object size exceeds maximum (total number of properties should be <=" ++ show n ++ ")")
    
          check minProperties $ \n ->
            when (size < n) $
              invalid ("object size is too small (total number of properties should be >=" ++ show n ++ ")")
    
          validateRequired
          validateProps
      where
        size = fromIntegral (HashMap.size o)
    
        validateRequired = withSchema $ \sch -> traverse_ validateReq (sch ^. required)
        validateReq n =
          when (not (HashMap.member n o)) $
            invalid ("property " ++ show n ++ " is required, but not found in " ++ show (encode o))
    
        validateProps = withSchema $ \sch -> do
          for_ (HashMap.toList o) $ \(k, v) ->
            case v of
    

    Found in Universum.Container.Class from the package universum
    ----------------------------------------------------------------------------
    
    instance Container (Set v) where
        type ElementConstraint (Set v) = Ord
        elem = Set.member
        {-# INLINE elem #-}
        notElem = Set.notMember
        {-# INLINE notElem #-}
    
    class (Eq a, Hashable a) => CanHash a
    instance (Eq a, Hashable a) => CanHash a
    
    instance Container (HashSet v) where
        type ElementConstraint (HashSet v) = CanHash
        elem = HashSet.member
        {-# INLINE elem #-}
    
    ----------------------------------------------------------------------------
    -- Boilerplate instances (duplicate Foldable)
    ----------------------------------------------------------------------------
    

    Found in Universum.Container.Class from the package universum
        {-# INLINE elem #-}
        maximum = IS.findMax
        {-# INLINE maximum #-}
        minimum = IS.findMin
        {-# INLINE minimum #-}
        safeHead = fmap fst . IS.minView
        {-# INLINE safeHead #-}
    
    ----------------------------------------------------------------------------
    -- Efficient instances
    ----------------------------------------------------------------------------
    
    instance Container (Set v) where
        type ElementConstraint (Set v) = Ord
        elem = Set.member
        {-# INLINE elem #-}
        notElem = Set.notMember
        {-# INLINE notElem #-}
    
    class (Eq a, Hashable a) => CanHash a
    

    Found in Universum.Container.Class from the package universum
    instance Container IntSet where
        type Element IntSet = Int
        toList = IS.toList
        {-# INLINE toList #-}
        null = IS.null
        {-# INLINE null #-}
        foldr = IS.foldr
        {-# INLINE foldr #-}
        foldl = IS.foldl
        {-# INLINE foldl #-}
        foldl' = IS.foldl'
        {-# INLINE foldl' #-}
        length = IS.size
        {-# INLINE length #-}
        elem = IS.member
        {-# INLINE elem #-}
        maximum = IS.findMax
        {-# INLINE maximum #-}
        minimum = IS.findMin
        {-# INLINE minimum #-}
    

    Found in Universum.Nub from the package universum
        go s (x:xs) =
          if x `Set.member` s
          then go s xs
          else x : go (Set.insert x s) xs
    
    -- | Like 'Prelude.nub' but runs in @O(n * log_16(n))@ time and requires 'Hashable'.
    --
    -- >>> hashNub [3, 3, 3, 2, 2, -1, 1]
    -- [3,2,-1,1]
    hashNub :: (Eq a, Hashable a) => [a] -> [a]
    hashNub = go HashSet.empty
      where
        go _ []     = []
        go s (x:xs) =
          if x `HashSet.member` s
          then go s xs
          else x : go (HashSet.insert x s) xs
    
    -- | Like 'ordNub' but also sorts a list.
    --
    

    Found in Universum.Nub from the package universum
          else (dups xs)}
    @-}
    
    {-@ Set.toList :: Set a -> ListUnique a @-}
    
    -- | Like 'Prelude.nub' but runs in @O(n * log n)@ time and requires 'Ord'.
    --
    -- >>> ordNub [3, 3, 3, 2, 2, -1, 1]
    -- [3,2,-1,1]
    ordNub :: (Ord a) => [a] -> [a]
    ordNub = go Set.empty
      where
        go _ []     = []
        go s (x:xs) =
          if x `Set.member` s
          then go s xs
          else x : go (Set.insert x s) xs
    
    -- | Like 'Prelude.nub' but runs in @O(n * log_16(n))@ time and requires 'Hashable'.
    --
    

    null See 11 Occurences [+] Collapse [-]
    Found in Data.Core.Graph.PureCore from the package graph-core
    fromAdj :: [(Node, [Node])] -> Graph
    fromAdj l =
        let g1 = fromEdges (adjToEdges l)
            solitaires = map fst $ filter (\(_, xs) -> null xs) l
        in L.foldl' (\g n -> g { g_adj = IM.insert n VU.empty (g_adj g) }) g1 solitaires
    
    nodes :: Graph -> [Node]
    nodes g = IM.keys (IM.union (g_adj g) (g_radj g))
    
    edges :: Graph -> [Edge]
    edges = edgesAdj . g_adj
    
    solitaireNodes :: Graph -> [Node]
    solitaireNodes g = IM.keys (IM.filter VU.null (IM.union (g_adj g) (g_radj g)))
    
    edgeCount :: Graph -> Int
    edgeCount = F.foldl' (\old (_,adj) -> old + VU.length adj) 0
              . IM.toList . g_adj
    

    Found in Data.Core.Graph.PureCore from the package graph-core
    fromEdges :: [Edge] -> Graph
    fromEdges edgeList =
        Graph { g_adj = mkAdj edgeList
              , g_radj = mkAdj $ map invert edgeList
              }
        where
          mkAdj e = IM.fromList $ map (src . head &&& VU.fromList . map tgt)
                            . L.groupBy ((==) `on` src)
                            . L.sortBy (compare `on` src) $ e
    
    fromAdj :: [(Node, [Node])] -> Graph
    fromAdj l =
        let g1 = fromEdges (adjToEdges l)
            solitaires = map fst $ filter (\(_, xs) -> null xs) l
        in L.foldl' (\g n -> g { g_adj = IM.insert n VU.empty (g_adj g) }) g1 solitaires
    
    nodes :: Graph -> [Node]
    nodes g = IM.keys (IM.union (g_adj g) (g_radj g))
    

    Found in Language.C.Inline.HaskellIdentifier from the package inline-c
                 , return [con]
                 ]
          , do var <- varid
               return [var]
          ]
    
    -- | Mangles an 'HaskellIdentifier' to produce a valid 'C.CIdentifier'
    -- which still sort of resembles the 'HaskellIdentifier'.
    mangleHaskellIdentifier :: HaskellIdentifier -> C.CIdentifier
    mangleHaskellIdentifier (HaskellIdentifier hs) =
      -- The leading underscore if we have no valid chars is because then
      -- we'd have an identifier starting with numbers.
      let cs = (if null valid then "_" else "") ++
               valid ++
               (if null mangled || null valid then "" else "_") ++
               mangled
      in case C.cIdentifierFromString cs of
        Left err -> error $ "mangleHaskellIdentifier: produced bad C identifier\n" ++ err
        Right x -> x
      where
    

    Found in Language.C.Inline.HaskellIdentifier from the package inline-c
                 , return [con]
                 ]
          , do var <- varid
               return [var]
          ]
    
    -- | Mangles an 'HaskellIdentifier' to produce a valid 'C.CIdentifier'
    -- which still sort of resembles the 'HaskellIdentifier'.
    mangleHaskellIdentifier :: HaskellIdentifier -> C.CIdentifier
    mangleHaskellIdentifier (HaskellIdentifier hs) =
      -- The leading underscore if we have no valid chars is because then
      -- we'd have an identifier starting with numbers.
      let cs = (if null valid then "_" else "") ++
               valid ++
               (if null mangled || null valid then "" else "_") ++
               mangled
      in case C.cIdentifierFromString cs of
        Left err -> error $ "mangleHaskellIdentifier: produced bad C identifier\n" ++ err
        Right x -> x
      where
    

    Found in Language.C.Inline.HaskellIdentifier from the package inline-c
                 [ do void $ char '.'
                      (con :) <$> go
                 , return [con]
                 ]
          , do var <- varid
               return [var]
          ]
    
    -- | Mangles an 'HaskellIdentifier' to produce a valid 'C.CIdentifier'
    -- which still sort of resembles the 'HaskellIdentifier'.
    mangleHaskellIdentifier :: HaskellIdentifier -> C.CIdentifier
    mangleHaskellIdentifier (HaskellIdentifier hs) =
      -- The leading underscore if we have no valid chars is because then
      -- we'd have an identifier starting with numbers.
      let cs = (if null valid then "_" else "") ++
               valid ++
               (if null mangled || null valid then "" else "_") ++
               mangled
      in case C.cIdentifierFromString cs of
        Left err -> error $ "mangleHaskellIdentifier: produced bad C identifier\n" ++ err
    

    Found in Language.C.Types.Parse from the package inline-c
       mbabstract =
         IsDeclarator <$> try declarator <|>
         IsAbstractDeclarator <$> try abstract_declarator <|>
         return (IsAbstractDeclarator (AbstractDeclarator [] Nothing))
    
    data AbstractDeclarator i = AbstractDeclarator
      { abstractDeclaratorPointers :: [Pointer]
      , abstractDeclaratorDirect :: Maybe (DirectAbstractDeclarator i)
      } deriving (Typeable, Eq, Show, Functor, Foldable, Traversable)
    
    abstract_declarator :: CParser i m => m (AbstractDeclarator i)
    abstract_declarator = do
      ptrs <- many pointer
      -- If there are no pointers, there must be an abstract declarator.
      let p = if null ptrs
            then Just <$> direct_abstract_declarator
            else (Just <$> try direct_abstract_declarator) <|> return Nothing
      AbstractDeclarator ptrs <$> p
    
    data DirectAbstractDeclarator i
    

    Found in Algebra.PartialOrd from the package lattices
    instance PartialOrd IS.IntSet where
        leq = IS.isSubsetOf
    
    instance (Eq k, Hashable k) => PartialOrd (HS.HashSet k) where
        leq a b = HS.null (HS.difference a b)
    
    instance (Ord k, PartialOrd v) => PartialOrd (M.Map k v) where
        leq = M.isSubmapOfBy leq
    
    instance PartialOrd v => PartialOrd (IM.IntMap v) where
        leq = IM.isSubmapOfBy leq
    
    instance (Eq k, Hashable k, PartialOrd v) => PartialOrd (HM.HashMap k v) where
        x `leq` y = {- wish: HM.isSubmapOfBy leq -}
            HM.null (HM.difference x y) && getAll (fold $ HM.intersectionWith (\vx vy -> All (vx `leq` vy)) x y)
    
    instance (PartialOrd a, PartialOrd b) => PartialOrd (a, b) where
        -- NB: *not* a lexical ordering. This is because for some component partial orders, lexical
        -- ordering is incompatible with the transitivity axiom we require for the derived partial order
        (x1, y1) `leq` (x2, y2) = x1 `leq` x2 && y1 `leq` y2
    

    Found in Algebra.PartialOrd from the package lattices
    instance PartialOrd Void where
        leq _ _ = True
    
    -- | @'leq' = 'Data.List.isInfixOf'@.
    instance Eq a => PartialOrd [a] where
        leq = L.isInfixOf
    
    instance Ord a => PartialOrd (S.Set a) where
        leq = S.isSubsetOf
    
    instance PartialOrd IS.IntSet where
        leq = IS.isSubsetOf
    
    instance (Eq k, Hashable k) => PartialOrd (HS.HashSet k) where
        leq a b = HS.null (HS.difference a b)
    
    instance (Ord k, PartialOrd v) => PartialOrd (M.Map k v) where
        leq = M.isSubmapOfBy leq
    
    instance PartialOrd v => PartialOrd (IM.IntMap v) where
    

    Found in Text.Parser.Token.Style from the package parsers
    -- | Use haskell-style comments
    haskellCommentStyle :: CommentStyle
    haskellCommentStyle = CommentStyle "{-" "-}" "--" True
    
    -- | Use this to easily build the definition of whiteSpace for your MonadParser
    --   given a comment style and an underlying someWhiteSpace parser
    buildSomeSpaceParser :: forall m. CharParsing m => m () -> CommentStyle -> m ()
    buildSomeSpaceParser simpleSpace (CommentStyle startStyle endStyle lineStyle nestingStyle)
      | noLine && noMulti  = skipSome (simpleSpace <?> "")
      | noLine             = skipSome (simpleSpace <|> multiLineComment <?> "")
      | noMulti            = skipSome (simpleSpace <|> oneLineComment <?> "")
      | otherwise          = skipSome (simpleSpace <|> oneLineComment <|> multiLineComment <?> "")
      where
        noLine  = null lineStyle
        noMulti = null startStyle
    
        oneLineComment, multiLineComment, inComment, inCommentMulti :: m ()
        oneLineComment = try (string lineStyle) *> skipMany (satisfy (/= '\n'))
        multiLineComment = try (string startStyle) *> inComment
        inComment = if nestingStyle then inCommentMulti else inCommentSingle
    

    Found in Text.Parser.Token.Style from the package parsers
    -- | Use haskell-style comments
    haskellCommentStyle :: CommentStyle
    haskellCommentStyle = CommentStyle "{-" "-}" "--" True
    
    -- | Use this to easily build the definition of whiteSpace for your MonadParser
    --   given a comment style and an underlying someWhiteSpace parser
    buildSomeSpaceParser :: forall m. CharParsing m => m () -> CommentStyle -> m ()
    buildSomeSpaceParser simpleSpace (CommentStyle startStyle endStyle lineStyle nestingStyle)
      | noLine && noMulti  = skipSome (simpleSpace <?> "")
      | noLine             = skipSome (simpleSpace <|> multiLineComment <?> "")
      | noMulti            = skipSome (simpleSpace <|> oneLineComment <?> "")
      | otherwise          = skipSome (simpleSpace <|> oneLineComment <|> multiLineComment <?> "")
      where
        noLine  = null lineStyle
        noMulti = null startStyle
    
        oneLineComment, multiLineComment, inComment, inCommentMulti :: m ()
        oneLineComment = try (string lineStyle) *> skipMany (satisfy (/= '\n'))
        multiLineComment = try (string startStyle) *> inComment
    

    Found in RIO.HashSet from the package rio
    -- > import qualified RIO.HashSet as HS
    module RIO.HashSet
      (
        Data.HashSet.HashSet
    
      -- * Construction
      , Data.HashSet.empty
      , Data.HashSet.singleton
    
      -- * Combine
      , Data.HashSet.union
      , Data.HashSet.unions
    
      -- * Basic interface
      , Data.HashSet.null
      , Data.HashSet.size
      , Data.HashSet.member
      , Data.HashSet.insert
      , Data.HashSet.delete
    

    singleton See 5 Occurences [+] Collapse [-]
    Found in RIO.HashSet from the package rio
    -- | @Set@ with hashed members. Import as:
    --
    -- > import qualified RIO.HashSet as HS
    module RIO.HashSet
      (
        Data.HashSet.HashSet
    
      -- * Construction
      , Data.HashSet.empty
      , Data.HashSet.singleton
    
      -- * Combine
      , Data.HashSet.union
      , Data.HashSet.unions
    

    Found in Data.Unfoldable.Restricted from the package unfoldable-restricted
    instance (Hashable a, Eq a) => Hashable' a
    
    
    instance UnfoldableR (Hashable') HashSet.HashSet where
      unfoldRestrict fa = choose
        [ pure HashSet.empty
        , HashSet.singleton <$> fa
        , HashSet.union <$> unfoldRestrict fa <*> unfoldRestrict fa
        ]
    
    instance BiunfoldableR (Hashable') (Unit) HashMap.HashMap where
      biunfoldRestrict fa fb = choose
        [ pure HashMap.empty
        , HashMap.singleton <$> fa <*> fb
        , HashMap.union <$> biunfoldRestrict fa fb <*> biunfoldRestrict fa fb
        ]
    
    -- Orig
    

    Found in Data.Unfoldable.Restricted from the package unfoldable-restricted
        ]
    
    
    -- * Utils
    
    
    class (Hashable a, Eq a) => Hashable' a
    
    instance (Hashable a, Eq a) => Hashable' a
    
    
    instance UnfoldableR (Hashable') HashSet.HashSet where
      unfoldRestrict fa = choose
        [ pure HashSet.empty
        , HashSet.singleton <$> fa
        , HashSet.union <$> unfoldRestrict fa <*> unfoldRestrict fa
        ]
    
    instance BiunfoldableR (Hashable') (Unit) HashMap.HashMap where
      biunfoldRestrict fa fb = choose
    

    Found in Data.Unfoldable.Restricted from the package unfoldable-restricted
        unconsB (as, b:bs) = Just (b, (as, bs))
    
    -- Containers
    
    instance UnfoldableR (Ord) Set.Set where
      unfoldRestrict fa = choose
        [ pure Set.empty
        , Set.singleton <$> fa
        , Set.union <$> unfoldRestrict fa <*> unfoldRestrict fa
        ]
    
    instance BiunfoldableR (Ord) Unit Map.Map where
      biunfoldRestrict fa fb = choose
        [ pure Map.empty
        , Map.singleton <$> fa <*> fb
        , Map.union <$> biunfoldRestrict fa fb <*> biunfoldRestrict fa fb
        ]
    
    
    -- * Utils
    

    Found in Data.Unfoldable.Restricted from the package unfoldable-restricted
    fromLists :: (BiunfoldableR p q t, p a, q b) => [a] -> [b] -> Maybe (t a b)
    fromLists = curry $ biunfoldrRestrict unconsA unconsB
      where
        unconsA ([],_)     = Nothing
        unconsA (a:as, bs) = Just (a, (as, bs))
        unconsB (_,[])     = Nothing
        unconsB (as, b:bs) = Just (b, (as, bs))
    
    -- Containers
    
    instance UnfoldableR (Ord) Set.Set where
      unfoldRestrict fa = choose
        [ pure Set.empty
        , Set.singleton <$> fa
        , Set.union <$> unfoldRestrict fa <*> unfoldRestrict fa
        ]
    
    instance BiunfoldableR (Ord) Unit Map.Map where
      biunfoldRestrict fa fb = choose
    

    size See 28 Occurences [+] Collapse [-]
    Found in Data.Core.Graph.PureCore from the package graph-core
                      (nodes a)
          where sameItems x y = IS.fromList x == IS.fromList y
    
    instance NFData Graph where
        rnf (Graph a b) = rnf a `seq` rnf b
    
    adjToEdges :: [(Node, [Node])] -> [Edge]
    adjToEdges = concatMap (\(x, ys) -> map (Edge x) ys)
    
    edgesAdj :: AdjList -> [Edge]
    edgesAdj adj = adjToEdges . map (second VU.toList) $ IM.toList adj
    
    isConsistent :: Graph -> Bool
    isConsistent (Graph{..}) = L.sort forwardEdges == L.sort (map invert (edgesAdj g_radj))
                            && HS.size (HS.fromList forwardEdges) == length forwardEdges
        where forwardEdges = edgesAdj g_adj
    
    fromEdges :: [Edge] -> Graph
    fromEdges edgeList =
        Graph { g_adj = mkAdj edgeList
    

    Found in Data.LargeHashable.Class from the package large-hashable
    updateHashIntMap :: LargeHashable a => IntMap.IntMap a -> LH ()
    updateHashIntMap !m = do
        IntMap.foldlWithKey' mapFoldFun (return ()) m
        updateHash (IntMap.size m)
    
    -- Lazy and Strict IntMap share the same definition
    instance LargeHashable a => LargeHashable (IntMap.IntMap a) where
        updateHash = updateHashIntMap
    
    updateHashHashMap :: (LargeHashable k, LargeHashable v) => HashMap.HashMap k v -> LH ()
    updateHashHashMap !m =
        -- The ordering of elements in a map do not matter. A HashMap does not
        -- offer an efficient way of exctracting its elements in some specific
        -- ordering. So we use the auxiliary function 'hashListModuloOrdering'.
        hashListModuloOrdering (HashMap.size m) (HashMap.toList m)
    
    -- Lazy and Strict HashMap share the same definition
    instance (LargeHashable k, LargeHashable v) => LargeHashable (HashMap.HashMap k v) where
        updateHash = updateHashHashMap
    

    Found in Data.LargeHashable.Class from the package large-hashable
    {-# INLINE updateHashMap #-}
    updateHashMap :: (LargeHashable k, LargeHashable a) => M.Map k a -> LH ()
    updateHashMap !m = do
            M.foldlWithKey' mapFoldFun (return ()) m
            updateHash (M.size m)
    
    -- Lazy and Strict Map share the same definition
    instance (LargeHashable k, LargeHashable a) => LargeHashable (M.Map k a) where
        updateHash = updateHashMap
    
    {-# INLINE updateHashIntMap #-}
    updateHashIntMap :: LargeHashable a => IntMap.IntMap a -> LH ()
    updateHashIntMap !m = do
        IntMap.foldlWithKey' mapFoldFun (return ()) m
        updateHash (IntMap.size m)
    
    -- Lazy and Strict IntMap share the same definition
    instance LargeHashable a => LargeHashable (IntMap.IntMap a) where
        updateHash = updateHashIntMap
    

    Found in Data.LargeHashable.Class from the package large-hashable
           updateHash len
    
    -- Lazy and Strict HashSet share the same definition
    instance LargeHashable a => LargeHashable (HashSet.HashSet a) where
        updateHash = updateHashHashSet
    
    {-# INLINE mapFoldFun #-}
    mapFoldFun :: (LargeHashable k, LargeHashable a) => LH () -> k -> a -> LH ()
    mapFoldFun action key value = action >> updateHash key >> updateHash value
    
    {-# INLINE updateHashMap #-}
    updateHashMap :: (LargeHashable k, LargeHashable a) => M.Map k a -> LH ()
    updateHashMap !m = do
            M.foldlWithKey' mapFoldFun (return ()) m
            updateHash (M.size m)
    
    -- Lazy and Strict Map share the same definition
    instance (LargeHashable k, LargeHashable a) => LargeHashable (M.Map k a) where
        updateHash = updateHashMap
    

    Found in Data.LargeHashable.Class from the package large-hashable
    updateHashIntSet !set = do
        IntSet.foldl' setFoldFun (return ()) set
        updateHash (IntSet.size set)
    
    -- Lazy and Strict IntSet share the same definition
    instance LargeHashable IntSet.IntSet where
        updateHash = updateHashIntSet
    
    {-# INLINE updateHashHashSet #-}
    updateHashHashSet :: LargeHashable a => HashSet.HashSet a -> LH ()
    updateHashHashSet !set =
        -- The ordering of elements in a set does not matter. A HashSet does not
        -- offer an efficient way of exctracting its elements in some specific
        -- ordering. So we use the auxiliary function 'hashListModuloOrdering'.
        hashListModuloOrdering (HashSet.size set) (HashSet.toList set)
    
    -- | Hashes a list of values such the two permutations of the same list
    -- yields the same hash.
    hashListModuloOrdering :: LargeHashable a => Int -> [a] -> LH ()
    hashListModuloOrdering len list =
    

    Found in Data.LargeHashable.Class from the package large-hashable
    {-# INLINE updateHashSet #-}
    updateHashSet :: LargeHashable a => S.Set a -> LH ()
    updateHashSet !set = do
        foldl' setFoldFun (return ()) set -- Note: foldl' for sets traverses the elements in asc order
        updateHash (S.size set)
    
    instance LargeHashable a => LargeHashable (S.Set a) where
        updateHash = updateHashSet
    
    {-# INLINE updateHashIntSet #-}
    updateHashIntSet :: IntSet.IntSet -> LH ()
    updateHashIntSet !set = do
        IntSet.foldl' setFoldFun (return ()) set
        updateHash (IntSet.size set)
    
    -- Lazy and Strict IntSet share the same definition
    instance LargeHashable IntSet.IntSet where
        updateHash = updateHashIntSet
    

    Found in Data.LargeHashable.Class from the package large-hashable
              updateHash x
              loop (i + 1) xs
    
    instance LargeHashable a => LargeHashable [a] where
        updateHash = updateHashList
    
    {-# INLINE setFoldFun #-}
    setFoldFun :: LargeHashable a => LH () -> a -> LH ()
    setFoldFun action value = action >> updateHash value
    
    {-# INLINE updateHashSet #-}
    updateHashSet :: LargeHashable a => S.Set a -> LH ()
    updateHashSet !set = do
        foldl' setFoldFun (return ()) set -- Note: foldl' for sets traverses the elements in asc order
        updateHash (S.size set)
    
    instance LargeHashable a => LargeHashable (S.Set a) where
        updateHash = updateHashSet
    
    {-# INLINE updateHashIntSet #-}
    

    Found in Relude.Extra.Map from the package relude
        size   = HS.size
        member = HS.member
        lookup k m = guard (member k m) *> pure k
        {-# INLINE size #-}
        {-# INLINE lookup #-}
        {-# INLINE member #-}
    
    instance StaticMap IntSet where
        type Key IntSet = Int
        type Val IntSet = Int
    
        size   = IS.size
        member = IS.member
        lookup k m = guard (member k m) *> pure k
        {-# INLINE size #-}
        {-# INLINE lookup #-}
        {-# INLINE member #-}
    
    -- | Operator version of 'lookup' function.
    infixl 9 !?
    

    Found in Relude.Extra.Map from the package relude
        type Key (HashSet a) = a
        type Val (HashSet a) = a
    
        size   = HS.size
        member = HS.member
        lookup k m = guard (member k m) *> pure k
        {-# INLINE size #-}
        {-# INLINE lookup #-}
        {-# INLINE member #-}
    
    instance StaticMap IntSet where
        type Key IntSet = Int
        type Val IntSet = Int
    
        size   = IS.size
        member = IS.member
        lookup k m = guard (member k m) *> pure k
        {-# INLINE size #-}
        {-# INLINE lookup #-}
        {-# INLINE member #-}
    

    Found in Relude.Extra.Map from the package relude
        type Key (HashSet a) = a
        type Val (HashSet a) = a
    
        size   = HS.size
        member = HS.member
        lookup k m = guard (member k m) *> pure k
        {-# INLINE size #-}
        {-# INLINE lookup #-}
        {-# INLINE member #-}
    
    instance StaticMap IntSet where
        type Key IntSet = Int
        type Val IntSet = Int
    
        size   = IS.size
        member = IS.member
        lookup k m = guard (member k m) *> pure k
        {-# INLINE size #-}
        {-# INLINE lookup #-}
        {-# INLINE member #-}
    

    Found in Relude.Extra.Map from the package relude
        size   = S.size
        member = S.member
        lookup k m = guard (member k m) *> pure k
        {-# INLINE size #-}
        {-# INLINE lookup #-}
        {-# INLINE member #-}
    
    instance (Eq a, Hashable a) => StaticMap (HashSet a) where
        type Key (HashSet a) = a
        type Val (HashSet a) = a
    
        size   = HS.size
        member = HS.member
        lookup k m = guard (member k m) *> pure k
        {-# INLINE size #-}
        {-# INLINE lookup #-}
        {-# INLINE member #-}
    
    instance StaticMap IntSet where
        type Key IntSet = Int
    

    Found in Relude.Extra.Map from the package relude
        type Key (Set a) = a
        type Val (Set a) = a
    
        size   = S.size
        member = S.member
        lookup k m = guard (member k m) *> pure k
        {-# INLINE size #-}
        {-# INLINE lookup #-}
        {-# INLINE member #-}
    
    instance (Eq a, Hashable a) => StaticMap (HashSet a) where
        type Key (HashSet a) = a
        type Val (HashSet a) = a
    
        size   = HS.size
        member = HS.member
        lookup k m = guard (member k m) *> pure k
        {-# INLINE size #-}
        {-# INLINE lookup #-}
        {-# INLINE member #-}
    

    Found in Relude.Extra.Map from the package relude
        type Key (Set a) = a
        type Val (Set a) = a
    
        size   = S.size
        member = S.member
        lookup k m = guard (member k m) *> pure k
        {-# INLINE size #-}
        {-# INLINE lookup #-}
        {-# INLINE member #-}
    
    instance (Eq a, Hashable a) => StaticMap (HashSet a) where
        type Key (HashSet a) = a
        type Val (HashSet a) = a
    
        size   = HS.size
        member = HS.member
        lookup k m = guard (member k m) *> pure k
        {-# INLINE size #-}
        {-# INLINE lookup #-}
        {-# INLINE member #-}
    

    Found in Relude.Extra.Map from the package relude
        size   = IM.size
        lookup = IM.lookup
        member = IM.member
        {-# INLINE size #-}
        {-# INLINE lookup #-}
        {-# INLINE member #-}
    
    instance Ord a => StaticMap (Set a) where
        type Key (Set a) = a
        type Val (Set a) = a
    
        size   = S.size
        member = S.member
        lookup k m = guard (member k m) *> pure k
        {-# INLINE size #-}
        {-# INLINE lookup #-}
        {-# INLINE member #-}
    
    instance (Eq a, Hashable a) => StaticMap (HashSet a) where
        type Key (HashSet a) = a
    

    Found in Relude.Extra.Map from the package relude
        type Key (IntMap v) = Int
        type Val (IntMap v) = v
    
        size   = IM.size
        lookup = IM.lookup
        member = IM.member
        {-# INLINE size #-}
        {-# INLINE lookup #-}
        {-# INLINE member #-}
    
    instance Ord a => StaticMap (Set a) where
        type Key (Set a) = a
        type Val (Set a) = a
    
        size   = S.size
        member = S.member
        lookup k m = guard (member k m) *> pure k
        {-# INLINE size #-}
        {-# INLINE lookup #-}
        {-# INLINE member #-}
    

    Found in Relude.Extra.Map from the package relude
        type Key (IntMap v) = Int
        type Val (IntMap v) = v
    
        size   = IM.size
        lookup = IM.lookup
        member = IM.member
        {-# INLINE size #-}
        {-# INLINE lookup #-}
        {-# INLINE member #-}
    
    instance Ord a => StaticMap (Set a) where
        type Key (Set a) = a
        type Val (Set a) = a
    
        size   = S.size
        member = S.member
        lookup k m = guard (member k m) *> pure k
        {-# INLINE size #-}
        {-# INLINE lookup #-}
        {-# INLINE member #-}
    

    Found in Relude.Extra.Map from the package relude
        size   = HM.size
        lookup = HM.lookup
        member = HM.member
        {-# INLINE size #-}
        {-# INLINE lookup #-}
        {-# INLINE member #-}
    
    instance StaticMap (IntMap v) where
        type Key (IntMap v) = Int
        type Val (IntMap v) = v
    
        size   = IM.size
        lookup = IM.lookup
        member = IM.member
        {-# INLINE size #-}
        {-# INLINE lookup #-}
        {-# INLINE member #-}
    
    instance Ord a => StaticMap (Set a) where
        type Key (Set a) = a
    

    Found in Relude.Extra.Map from the package relude
        type Key (HashMap k v) = k
        type Val (HashMap k v) = v
    
        size   = HM.size
        lookup = HM.lookup
        member = HM.member
        {-# INLINE size #-}
        {-# INLINE lookup #-}
        {-# INLINE member #-}
    
    instance StaticMap (IntMap v) where
        type Key (IntMap v) = Int
        type Val (IntMap v) = v
    
        size   = IM.size
        lookup = IM.lookup
        member = IM.member
        {-# INLINE size #-}
        {-# INLINE lookup #-}
        {-# INLINE member #-}
    

    Found in Relude.Extra.Map from the package relude
        type Key (HashMap k v) = k
        type Val (HashMap k v) = v
    
        size   = HM.size
        lookup = HM.lookup
        member = HM.member
        {-# INLINE size #-}
        {-# INLINE lookup #-}
        {-# INLINE member #-}
    
    instance StaticMap (IntMap v) where
        type Key (IntMap v) = Int
        type Val (IntMap v) = v
    
        size   = IM.size
        lookup = IM.lookup
        member = IM.member
        {-# INLINE size #-}
        {-# INLINE lookup #-}
        {-# INLINE member #-}
    

    Found in Relude.Extra.Map from the package relude
        size   = M.size
        lookup = M.lookup
        member = M.member
        {-# INLINE size #-}
        {-# INLINE lookup #-}
        {-# INLINE member #-}
    
    instance (Eq k, Hashable k) => StaticMap (HashMap k v) where
        type Key (HashMap k v) = k
        type Val (HashMap k v) = v
    
        size   = HM.size
        lookup = HM.lookup
        member = HM.member
        {-# INLINE size #-}
        {-# INLINE lookup #-}
        {-# INLINE member #-}
    
    instance StaticMap (IntMap v) where
        type Key (IntMap v) = Int
    

    Found in Relude.Extra.Map from the package relude
        type Key (Map k v) = k
        type Val (Map k v) = v
    
        size   = M.size
        lookup = M.lookup
        member = M.member
        {-# INLINE size #-}
        {-# INLINE lookup #-}
        {-# INLINE member #-}
    
    instance (Eq k, Hashable k) => StaticMap (HashMap k v) where
        type Key (HashMap k v) = k
        type Val (HashMap k v) = v
    
        size   = HM.size
        lookup = HM.lookup
        member = HM.member
        {-# INLINE size #-}
        {-# INLINE lookup #-}
        {-# INLINE member #-}
    

    Found in Relude.Extra.Map from the package relude
        type Key (Map k v) = k
        type Val (Map k v) = v
    
        size   = M.size
        lookup = M.lookup
        member = M.member
        {-# INLINE size #-}
        {-# INLINE lookup #-}
        {-# INLINE member #-}
    
    instance (Eq k, Hashable k) => StaticMap (HashMap k v) where
        type Key (HashMap k v) = k
        type Val (HashMap k v) = v
    
        size   = HM.size
        lookup = HM.lookup
        member = HM.member
        {-# INLINE size #-}
        {-# INLINE lookup #-}
        {-# INLINE member #-}
    

    Found in Relude.Extra.Map from the package relude
        type Key t :: Type
        type Val t :: Type
    
        size   :: t -> Int
        lookup :: Key t -> t -> Maybe (Val t)
        member :: Key t -> t -> Bool
    
    instance Ord k => StaticMap (Map k v) where
        type Key (Map k v) = k
        type Val (Map k v) = v
    
        size   = M.size
        lookup = M.lookup
        member = M.member
        {-# INLINE size #-}
        {-# INLINE lookup #-}
        {-# INLINE member #-}
    
    instance (Eq k, Hashable k) => StaticMap (HashMap k v) where
        type Key (HashMap k v) = k
    

    Found in Relude.Extra.Map from the package relude
    sets and maps.
    -}
    class StaticMap t where
        type Key t :: Type
        type Val t :: Type
    
        size   :: t -> Int
        lookup :: Key t -> t -> Maybe (Val t)
        member :: Key t -> t -> Bool
    
    instance Ord k => StaticMap (Map k v) where
        type Key (Map k v) = k
        type Val (Map k v) = v
    
        size   = M.size
        lookup = M.lookup
        member = M.member
        {-# INLINE size #-}
        {-# INLINE lookup #-}
        {-# INLINE member #-}
    

    Found in Relude.Extra.Map from the package relude
    sets and maps.
    -}
    class StaticMap t where
        type Key t :: Type
        type Val t :: Type
    
        size   :: t -> Int
        lookup :: Key t -> t -> Maybe (Val t)
        member :: Key t -> t -> Bool
    
    instance Ord k => StaticMap (Map k v) where
        type Key (Map k v) = k
        type Val (Map k v) = v
    
        size   = M.size
        lookup = M.lookup
        member = M.member
        {-# INLINE size #-}
        {-# INLINE lookup #-}
        {-# INLINE member #-}
    

    Found in Relude.Extra.Map from the package relude
    import qualified Data.Map.Strict as M
    import qualified Data.Set as S
    
    ----------------------------------------------------------------------------
    -- Static Map
    ----------------------------------------------------------------------------
    
    {- | Read-only map or set. Contains polymorhic functions which work for both
    sets and maps.
    -}
    class StaticMap t where
        type Key t :: Type
        type Val t :: Type
    
        size   :: t -> Int
        lookup :: Key t -> t -> Maybe (Val t)
        member :: Key t -> t -> Bool
    
    instance Ord k => StaticMap (Map k v) where
        type Key (Map k v) = k
    

    Found in RIO.HashSet from the package rio
    module RIO.HashSet
      (
        Data.HashSet.HashSet
    
      -- * Construction
      , Data.HashSet.empty
      , Data.HashSet.singleton
    
      -- * Combine
      , Data.HashSet.union
      , Data.HashSet.unions
    
      -- * Basic interface
      , Data.HashSet.null
      , Data.HashSet.size
      , Data.HashSet.member
      , Data.HashSet.insert
      , Data.HashSet.delete
    
      -- * Transformations
    

    Found in Universum.Container.Class from the package universum
        {-# INLINE safeHead #-}
    
    instance Container IntSet where
        type Element IntSet = Int
        toList = IS.toList
        {-# INLINE toList #-}
        null = IS.null
        {-# INLINE null #-}
        foldr = IS.foldr
        {-# INLINE foldr #-}
        foldl = IS.foldl
        {-# INLINE foldl #-}
        foldl' = IS.foldl'
        {-# INLINE foldl' #-}
        length = IS.size
        {-# INLINE length #-}
        elem = IS.member
        {-# INLINE elem #-}
        maximum = IS.findMax
        {-# INLINE maximum #-}
    

    toList See 33 Occurences [+] Collapse [-]
    Found in Database.Beam.Migrate.Simple from the package beam-migrate
    -- | Verify that the given, beam database matches the actual
    -- schema. On success, returns 'VerificationSucceeded', on failure,
    -- returns 'VerificationFailed' and a list of missing predicates.
    verifySchema :: ( Database be db, MonadBeam cmd be handle m )
                 => BeamMigrationBackend cmd be handle m
                 -> CheckedDatabaseSettings be db
                 -> m VerificationResult
    verifySchema BeamMigrationBackend { backendGetDbConstraints = getConstraints } db =
      do actualSchema <- HS.fromList <$> getConstraints
         let expectedSchema = HS.fromList (collectChecks db)
             missingPredicates = expectedSchema `HS.difference` actualSchema
         if HS.null missingPredicates
           then pure VerificationSucceeded
           else pure (VerificationFailed (HS.toList missingPredicates))
    
    -- | Run a sequence of commands on a database
    runSimpleMigration :: forall cmd be hdl m . MonadBeam cmd be hdl m
                       => hdl -> [cmd] -> IO ()
    runSimpleMigration hdl =
    

    Found in Data.Binary.Orphans from the package binary-orphans
    -- | /Since: binary-orphans-0.1.3.0/
    instance Binary a => Binary (Semigroup.Last a) where
      get = fmap Semigroup.Last get
      put = put . Semigroup.getLast
    
    -- | /Since: binary-orphans-0.1.3.0/
    instance Binary a => Binary (Semigroup.Option a) where
      get = fmap Semigroup.Option get
      put = put . Semigroup.getOption
    
    -- | /Since: binary-orphans-0.1.3.0/
    instance Binary a => Binary (NE.NonEmpty a) where
      get = fmap NE.fromList get
      put = put . NE.toList
    
    -- | /Since: binary-orphans-0.1.5.0/
    instance Binary m => Binary (Semigroup.WrappedMonoid m) where
      get = fmap Semigroup.WrapMonoid get
      put = put . Semigroup.unwrapMonoid
    

    Found in Data.Binary.Orphans from the package binary-orphans
      put (A.Object v) = put (0 :: Int) >> put v
      put (A.Array v)  = put (1 :: Int) >> put v
      put (A.String v) = put (2 :: Int) >> put v
      put (A.Number v) = put (3 :: Int) >> put v
      put (A.Bool v)   = put (4 :: Int) >> put v
      put A.Null       = put (5 :: Int)
    
    
    instance  (Hashable.Hashable k, Eq k, Binary