Hoogle Search

Within LTS Haskell 24.36 (ghc-9.10.3)

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

  1. module GHC.Prim.Panic

    Primitive panics. Users should not import this module. It is GHC internal only.

  2. module GHC.Prim.PtrEq

    Comparing underlying pointers for equality. Use GHC.Exts from the base package instead of importing this module directly.

  3. module GHC.PrimopWrappers

    Users should not import this module. It is GHC internal only. Use GHC.Exts instead.

  4. pattern PatternMatchFail_ :: AsPatternMatchFail s => String -> s

    lens Control.Exception.Lens

    No documentation available.

  5. pattern PatternMatchFail__ :: AsPatternMatchFail s => PatternMatchFail -> s

    lens Control.Exception.Lens

    No documentation available.

  6. class Plated a

    lens Control.Lens.Combinators

    A Plated type is one where we know how to extract its immediate self-similar children. Example 1:

    import Control.Applicative
    import Control.Lens
    import Control.Lens.Plated
    import Data.Data
    import Data.Data.Lens (uniplate)
    
    data Expr
    = Val Int
    | Neg Expr
    | Add Expr Expr
    deriving (Eq,Ord,Show,Read,Data)
    
    instance Plated Expr where
    plate f (Neg e) = Neg <$> f e
    plate f (Add a b) = Add <$> f a <*> f b
    plate _ a = pure a
    
    or
    instance Plated Expr where
    plate = uniplate
    
    Example 2:
    import Control.Applicative
    import Control.Lens
    import Control.Lens.Plated
    import Data.Data
    import Data.Data.Lens (uniplate)
    
    data Tree a
    = Bin (Tree a) (Tree a)
    | Tip a
    deriving (Eq,Ord,Show,Read,Data)
    
    instance Plated (Tree a) where
    plate f (Bin l r) = Bin <$> f l <*> f r
    plate _ t = pure t
    
    or
    instance Data a => Plated (Tree a) where
    plate = uniplate
    
    Note the big distinction between these two implementations. The former will only treat children directly in this tree as descendents, the latter will treat trees contained in the values under the tips also as descendants! When in doubt, pick a Traversal and just use the various ...Of combinators rather than pollute Plated with orphan instances! If you want to find something unplated and non-recursive with biplate use the ...OnOf variant with ignored, though those usecases are much better served in most cases by using the existing Lens combinators! e.g.
    toListOf biplateuniverseOnOf biplate ignored
    
    This same ability to explicitly pass the Traversal in question is why there is no analogue to uniplate's Biplate. Moreover, since we can allow custom traversals, we implement reasonable defaults for polymorphic data types, that only traverse into themselves, and not their polymorphic arguments.

  7. class Prefixed t

    lens Control.Lens.Combinators

    No documentation available.

  8. type Prism s t a b = forall (p :: Type -> Type -> Type) (f :: Type -> Type) . (Choice p, Applicative f) => p a f b -> p s f t

    lens Control.Lens.Combinators

    A Prism l is a Traversal that can also be turned around with re to obtain a Getter in the opposite direction. There are three laws that a Prism should satisfy: First, if I re or review a value with a Prism and then preview or use (^?), I will get it back:

    preview l (review l b) ≡ Just b
    
    Second, if you can extract a value a using a Prism l from a value s, then the value s is completely described by l and a:
    preview l s ≡ Just a ⟹ review l a ≡ s
    
    Third, if you get non-match t, you can convert it result back to s:
    matching l s ≡ Left t ⟹ matching l t ≡ Left s
    
    The first two laws imply that the Traversal laws hold for every Prism and that we traverse at most 1 element:
    lengthOf l x <= 1
    
    It may help to think of this as an Iso that can be partial in one direction. Every Prism is a valid Traversal. Every Iso is a valid Prism. For example, you might have a Prism' Integer Natural allows you to always go from a Natural to an Integer, and provide you with tools to check if an Integer is a Natural and/or to edit one if it is.
    nat :: Prism' Integer Natural
    nat = prism toInteger $ \ i ->
    if i < 0
    then Left i
    else Right (fromInteger i)
    
    Now we can ask if an Integer is a Natural.
    >>> 5^?nat
    Just 5
    
    >>> (-5)^?nat
    Nothing
    
    We can update the ones that are:
    >>> (-3,4) & both.nat *~ 2
    (-3,8)
    
    And we can then convert from a Natural to an Integer.
    >>> 5 ^. re nat -- :: Natural
    5
    
    Similarly we can use a Prism to traverse the Left half of an Either:
    >>> Left "hello" & _Left %~ length
    Left 5
    
    or to construct an Either:
    >>> 5^.re _Left
    Left 5
    
    such that if you query it with the Prism, you will get your original input back.
    >>> 5^.re _Left ^? _Left
    Just 5
    
    Another interesting way to think of a Prism is as the categorical dual of a Lens -- a co-Lens, so to speak. This is what permits the construction of outside. Note: Composition with a Prism is index-preserving.

  9. Prism :: Prism s t a b -> ReifiedPrism s t a b

    lens Control.Lens.Combinators

    No documentation available.

  10. type Prism' s a = Prism s s a a

    lens Control.Lens.Combinators

    A Simple Prism.

Page 42 of many | Previous | Next