Hoogle Search
Within LTS Haskell 24.39 (ghc-9.10.3)
Note that Stackage only displays results for the latest LTS and Nightly snapshot. Learn more.
mkWeakThreadId :: ThreadId -> IO (Weak ThreadId)base Control.Concurrent Make a weak pointer to a ThreadId. It can be important to do this if you want to hold a reference to a ThreadId while still allowing the thread to receive the BlockedIndefinitely family of exceptions (e.g. BlockedIndefinitelyOnMVar). Holding a normal ThreadId reference will prevent the delivery of BlockedIndefinitely exceptions because the reference could be used as the target of throwTo at any time, which would unblock the thread. Holding a Weak ThreadId, on the other hand, will not prevent the thread from receiving BlockedIndefinitely exceptions. It is still possible to throw an exception to a Weak ThreadId, but the caller must use deRefWeak first to determine whether the thread still exists.
-
base Control.Concurrent Returns the ThreadId of the calling thread (GHC only).
DivideByZero :: ArithExceptionbase Control.Exception No documentation available.
DivideByZero :: ArithExceptionbase Control.Exception.Base No documentation available.
void :: Functor f => f a -> f ()base Data.Functor void value discards or ignores the result of evaluation, such as the return value of an IO action.
Examples
Replace the contents of a Maybe Int with unit:>>> void Nothing Nothing
>>> void (Just 3) Just ()
Replace the contents of an Either Int Int with unit, resulting in an Either Int ():>>> void (Left 8675309) Left 8675309
>>> void (Right 8675309) Right ()
Replace every element of a list with unit:>>> void [1,2,3] [(),(),()]
Replace the second element of a pair with unit:>>> void (1,2) (1,())
Discard the result of an IO action:>>> mapM print [1,2] 1 2 [(),()]
>>> void $ mapM print [1,2] 1 2
runIdentity :: Identity a -> abase Data.Functor.Identity No documentation available.
-
A type a is a Monoid if it provides an associative function (<>) that lets you combine any two values of type a into one, and a neutral element (mempty) such that
a <> mempty == mempty <> a == a
A Monoid is a Semigroup with the added requirement of a neutral element. Thus any Monoid is a Semigroup, but not the other way around.Examples
The Sum monoid is defined by the numerical addition operator and `0` as neutral element:>>> mempty :: Sum Int Sum {getSum = 0} >>> Sum 1 <> Sum 2 <> Sum 3 <> Sum 4 :: Sum Int Sum {getSum = 10}We can combine multiple values in a list into a single value using the mconcat function. Note that we have to specify the type here since Int is a monoid under several different operations:>>> mconcat [1,2,3,4] :: Sum Int Sum {getSum = 10} >>> mconcat [] :: Sum Int Sum {getSum = 0}Another valid monoid instance of Int is Product It is defined by multiplication and `1` as neutral element:>>> Product 1 <> Product 2 <> Product 3 <> Product 4 :: Product Int Product {getProduct = 24} >>> mconcat [1,2,3,4] :: Product Int Product {getProduct = 24} >>> mconcat [] :: Product Int Product {getProduct = 1} -
base Data.Monoid The class of monoids (types with an associative binary operation that has an identity). Instances should satisfy the following:
- Right identity x <> mempty = x
- Left identity mempty <> x = x
- Associativity x <> (y <> z) = (x <> y) <> z (Semigroup law)
- Concatenation mconcat = foldr (<>) mempty
- Unit mconcat (pure x) = x
- Multiplication mconcat (join xss) = mconcat (fmap mconcat xss)
- Subclass mconcat (toList xs) = sconcat xs
WrapMonoid :: m -> WrappedMonoid mbase Data.Semigroup No documentation available.
-
base Data.Semigroup Provide a Semigroup for an arbitrary Monoid. NOTE: This is not needed anymore since Semigroup became a superclass of Monoid in base-4.11 and this newtype be deprecated at some point in the future.