packages feed

total 1.0.1 → 1.0.2

raw patch · 2 files changed

+16/−4 lines, 2 files

Files

src/Lens/Family/Total.hs view
@@ -15,12 +15,12 @@ -- >     & on _Left  (\c -> replicate 3  c )  --     Left  c -> replicate 3 c -- >     & on _Right (\n -> replicate n '!')  --     Right n -> replicate n '!' ----- Our @example@ function pattern matches exhaustively on the `Either` type using+-- Our @total@ function pattern matches exhaustively on the `Either` type using -- the `Lens.Family.Stock._Left` and `Lens.Family.Stock._Right` prisms: ----- >>> example (Left 'X')+-- >>> total (Left 'X') -- "XXX"--- >>> example (Right 2)+-- >>> total (Right 2) -- "!!" -- -- The types ensure that the above function is total.  For example, if you omit@@ -70,6 +70,12 @@ -- longer needs to be handled.  `_case` just verifies that all type parameters are -- `Void`. --+-- You can still write an inexhaustive pattern match so long as you provide a+-- default:+-- > example :: Example Int String Float -> String+-- > example = _default "default"+-- >     & on _C2 (\s -> s)+-- -- You can even pattern match using `Lens.Family.Lens`es, too: -- -- > example :: (Int, Char) -> String     -- Same as:@@ -85,6 +91,7 @@ module Lens.Family.Total (       Empty(..)     , _case+    , _default     , on     , (&) @@ -134,6 +141,11 @@ -- | Synonym for `impossible`, used to check if a pattern match is exhaustive _case :: Empty a => a -> x _case = impossible++-- | Synonym for `const`, used to provide a default if a pattern match is+-- inexhaustive+_default :: x -> a -> x+_default x _ = x  -- | Pattern match on a `Lens.Family.Traversal` on
total.cabal view
@@ -1,5 +1,5 @@ Name: total-Version: 1.0.1+Version: 1.0.2 Cabal-Version: >=1.8.0.2 Build-Type: Simple License: BSD3