Hoogle Search

Within LTS Haskell 24.33 (ghc-9.10.3)

Note that Stackage only displays results for the latest LTS and Nightly snapshot. Learn more.

  1. mapMutable' :: forall m (arr :: Type -> Type) a . (PrimMonad m, Contiguous arr, Element arr a) => (a -> a) -> Mutable arr (PrimState m) a -> m ()

    contiguous Data.Primitive.Contiguous

    Strictly map over a mutable array, modifying the elements in place.

  2. mapOrHead :: (Num a, Eq a) => a -> (t -> b) -> [t] -> ([b] -> b) -> b

    dbus DBus.Generation

    No documentation available.

  3. mapMaybe :: Ord k => (a -> Maybe b) -> Map k a -> Map k b

    dhall Dhall.Map

    Transform all values in a Map using the supplied function, deleting the key if the function returns Nothing

    >>> mapMaybe Data.Maybe.listToMaybe (fromList [("C",[1]),("B",[]),("A",[3])])
    fromList [("C",1),("A",3)]
    

  4. mapWithKey :: (k -> a -> b) -> Map k a -> Map k b

    dhall Dhall.Map

    Transform the values of a Map using their corresponding key

    mapWithKey (pure id) = id
    
    mapWithKey (liftA2 (.) f g) = mapWithKey f . mapWithKey g
    
    mapWithKey f mempty = mempty
    
    mapWithKey f (x <> y) = mapWithKey f x <> mapWithKey f y
    
    >>> mapWithKey (,) (fromList [("B",1),("A",2)])
    fromList [("B",("B",1)),("A",("A",2))]
    

  5. mapMOf :: LensLike (WrappedMonad m) s t a b -> (a -> m b) -> s -> m t

    dhall Dhall.Optics

    Identical to Control.Lens.mapMOf

  6. mapperIsLabelDeriver :: Deriver

    domain Domain

    Generates instances of IsLabel for sums and products, providing mappers over their components.

    Product Example

    Having the following schema:
    NetworkAddress:
    product:
    protocol: TransportProtocol
    host: Host
    port: Word16
    
    The following instances will be generated:
    instance
    mapper ~ (TransportProtocol -> TransportProtocol) =>
    IsLabel "protocol" (mapper -> NetworkAddress -> NetworkAddress)
    where
    fromLabel mapper (NetworkAddress a b c) =
    NetworkAddress (mapper a) b c
    
    instance
    mapper ~ (Host -> Host) =>
    IsLabel "host" (mapper -> NetworkAddress -> NetworkAddress)
    where
    fromLabel mapper (NetworkAddress a b c) =
    NetworkAddress a (mapper b) c
    
    instance
    mapper ~ (Word16 -> Word16) =>
    IsLabel "port" (mapper -> NetworkAddress -> NetworkAddress)
    where
    fromLabel mapper (NetworkAddress a b c) =
    NetworkAddress a b (mapper c)
    
    In case you're wondering what this tilde (~) constraint business is about, refer to the Type Equality Constraint section.

    Sum Example

    Having the following schema:
    Host:
    sum:
    ip: Ip
    name: Text
    
    The following instances will be generated:
    instance
    mapper ~ (Ip -> Ip) =>
    IsLabel "ip" (mapper -> Host -> Host)
    where
    fromLabel fn (IpHost a) = IpHost (fn a)
    fromLabel _ a = a
    
    instance
    mapper ~ (Text -> Text) =>
    IsLabel "name" (mapper -> Host -> Host)
    where
    fromLabel fn (NameHost a) = NameHost (fn a)
    fromLabel _ a = a
    
    In case you're wondering what this tilde (~) constraint business is about, refer to the Type Equality Constraint section.

  7. mapException :: (Exception e1, Exception e2) => (e1 -> e2) -> a -> a

    effectful-core Effectful.Exception

    This function maps one exception into another as proposed in the paper "A semantics for imprecise exceptions".

  8. mapConsts :: (Expr -> Expr) -> Expr -> Expr

    express Data.Express

    O(n*m). Applies a function to all terminal constants in an expression. Given that:

    > let one   = val (1 :: Int)
    > let two   = val (2 :: Int)
    > let xx -+- yy = value "+" ((+) :: Int->Int->Int) :$ xx :$ yy
    > let intToZero e = if typ e == typ zero then zero else e
    
    Then:
    > one -+- (two -+- xx)
    1 + (2 + x) :: Int
    
    > mapConsts intToZero (one -+- (two -+- xx))
    0 + (0 + x) :: Integer
    
    Given that the argument function is O(m), this function is O(n*m).

  9. mapSubexprs :: (Expr -> Maybe Expr) -> Expr -> Expr

    express Data.Express

    O(n*m). Substitute subexpressions of an expression using the given function. Outer expressions have more precedence than inner expressions. (cf. //) With:

    > let xx = var "x" (undefined :: Int)
    > let yy = var "y" (undefined :: Int)
    > let zz = var "z" (undefined :: Int)
    > let plus = value "+" ((+) :: Int->Int->Int)
    > let times = value "*" ((*) :: Int->Int->Int)
    > let xx -+- yy = plus :$ xx :$ yy
    > let xx -*- yy = times :$ xx :$ yy
    
    > let pluswap (o :$ xx :$ yy) | o == plus = Just $ o :$ yy :$ xx
    |     pluswap _                           = Nothing
    
    Then:
    > mapSubexprs pluswap $ (xx -*- yy) -+- (yy -*- zz)
    y * z + x * y :: Int
    
    > mapSubexprs pluswap $ (xx -+- yy) -*- (yy -+- zz)
    (y + x) * (z + y) :: Int
    
    Substitutions do not stack, in other words a replaced expression or its subexpressions are not further replaced:
    > mapSubexprs pluswap $ (xx -+- yy) -+- (yy -+- zz)
    (y + z) + (x + y) :: Int
    
    Given that the argument function is O(m), this function is O(n*m).

  10. mapValues :: (Expr -> Expr) -> Expr -> Expr

    express Data.Express

    O(n*m). Applies a function to all terminal values in an expression. (cf. //-) Given that:

    > let zero  = val (0 :: Int)
    > let one   = val (1 :: Int)
    > let two   = val (2 :: Int)
    > let three = val (3 :: Int)
    > let xx -+- yy = value "+" ((+) :: Int->Int->Int) :$ xx :$ yy
    > let intToZero e = if typ e == typ zero then zero else e
    
    Then:
    > one -+- (two -+- three)
    1 + (2 + 3) :: Int
    
    > mapValues intToZero $ one -+- (two -+- three)
    0 + (0 + 0) :: Integer
    
    Given that the argument function is O(m), this function is O(n*m).

Page 230 of many | Previous | Next