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. 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.Type

    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.

  2. type Prism' s a = Prism s s a a

    lens Control.Lens.Type

    A Simple Prism.

  3. pattern Polar :: RealFloat a => a -> a -> Complex a

    lens Data.Complex.Lens

    No documentation available.

  4. class Prefixed t

    lens Data.List.Lens

    No documentation available.

  5. pattern Pair :: Natural -> Natural -> Natural

    lens Numeric.Natural.Lens

    interleaves the bits of two natural numbers

  6. data PortNumber

    network Network.Socket

    Port number. Use the Num instance (i.e. use a literal) to create a PortNumber value.

    >>> 1 :: PortNumber
    1
    
    >>> read "1" :: PortNumber
    1
    
    >>> show (12345 :: PortNumber)
    "12345"
    
    >>> 50000 < (51000 :: PortNumber)
    True
    
    >>> 50000 < (52000 :: PortNumber)
    True
    
    >>> 50000 + (10000 :: PortNumber)
    60000
    

  7. type ProtocolNumber = CInt

    network Network.Socket

    Protocol number.

  8. pattern Pseudo_AF_HDRCMPLT :: Family

    network Network.Socket

    Used by BPF to not rewrite hdrs in iface output

  9. pattern Pseudo_AF_KEY :: Family

    network Network.Socket

    Internal key-management function

  10. pattern Pseudo_AF_PIP :: Family

    network Network.Socket

    Help Identify PIP packets

Page 45 of many | Previous | Next