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.
-
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. type
Prism' s a = Prism s s a alens Control.Lens.Type pattern
Polar :: RealFloat a => a -> a -> Complex alens Data.Complex.Lens No documentation available.
-
lens Data.List.Lens No documentation available.
pattern
Pair :: Natural -> Natural -> Naturallens Numeric.Natural.Lens interleaves the bits of two natural numbers
-
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
-
network Network.Socket Protocol number.
pattern
Pseudo_AF_HDRCMPLT :: Familynetwork Network.Socket Used by BPF to not rewrite hdrs in iface output
pattern
Pseudo_AF_KEY :: Familynetwork Network.Socket Internal key-management function
pattern
Pseudo_AF_PIP :: Familynetwork Network.Socket Help Identify PIP packets