HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Modulegenvalidity-sydtest-lens-1.0.0.0Haskell2010

Test.Syd.Validity.Lens

Standard test Specs for optics

  • 12 values
valuelensSpecOnGen
  1. :: (Show b, Eq b, Validity b, Show s, Eq s, Validity s)
  2. => Lens s s b b
  3. -> Gen b
  4. -> String
  5. -> b -> [b]
  6. -> Gen s
  7. -> String
  8. -> s -> [s]
  9. -> Spec
#

Standard test spec for properties lenses for values generated by given generators

Example usage:

lensSpecOnGen
     ((_2) :: Lens (Rational, Rational) (Rational, Rational) Rational Rational)
     (abs <$> genValid)
     "positive valid doubles"
     (filter (0.0 >=) . shrinkValid)
     ((,) <$> (negate . abs <$> genValid) <*> (negate . abs <$> genValid))
     "tuples of negative valid doubles"
     (const [])
valuelensLaw1
  1. :: (Show b, Eq b, Show s)
  2. => Lens s s b b
  3. -> Gen b
  4. -> b -> [b]
  5. -> Gen s
  6. -> s -> [s]
  7. -> Property
#

A property combinator for the first lens law:

view l (set l v s)  ≡ v

Example usage:

Property
lensLaw1 ((_2) :: Lens (Rational, Rational) (Rational, Rational) Rational Rational) genValid shrinkValid genValid shrinkValid
valuelensLaw2
  1. :: (Show s, Eq s)
  2. => Lens s s b b
  3. -> Gen s
  4. -> s -> [s]
  5. -> Property
#

A property combinator for the second lens law:

set l (view l s) s  ≡ s

Example usage:

Property
lensLaw2 ((_2) :: Lens (Rational, Rational) (Rational, Rational) Rational Rational) genValid shrinkValid
valuelensLaw3
  1. :: (Show b, Show s, Eq s)
  2. => Lens s s a b
  3. -> Gen b
  4. -> b -> [b]
  5. -> Gen s
  6. -> s -> [s]
  7. -> Property
#

A property combinator for the third lens law:

set l v' (set l v s) ≡ set l v' s

Example usage:

Property
lensLaw3 ((_2) :: Lens (Rational, Rational) (Rational, Rational) Rational Rational) genValid shrinkValid genValid shrinkValid
valuelensGettingProducesValidOnGen
  1. :: (Validity b, Show b, Show s)
  2. => Lens s s b b
  3. -> Gen s
  4. -> s -> [s]
  5. -> Property
#

A property combinator to test whether getting values generated by given a generator via a lens on values generated by a given generator produces valid values.

isValid (view l s)

Example Usage:

Property
lensGettingProducesValidOnGen ((_2) :: Lens (Rational, Rational) (Rational, Rational) Rational Rational) genValid shrinkValid
valuelensSettingProducesValidOnGen
  1. :: (Show s, Show b, Show t, Validity t)
  2. => Lens s t a b
  3. -> Gen b
  4. -> b -> [b]
  5. -> Gen s
  6. -> s -> [s]
  7. -> Property
#

A property combinator to test whether setting values generated by given a generator via a lens on values generated by a given generator produces valid values.

isValid (set l b s)

Example usage:

Property
lensSettingProducesValidOnGen ((_2) :: Lens (Rational, Rational) (Rational, Rational) Rational Rational) genValid shrinkValid genValid shrinkValid