lens-properties-4.11.1: QuickCheck properties for lens

Control.Lens.Properties

Description

A collection of properties that can be tested with QuickCheck, to guarantee that you are working with valid Lenses, Setters, Traversals, Isos and Prisms.

Synopsis

# Documentation

isLens :: (Arbitrary s, Arbitrary a, CoArbitrary a, Show s, Show a, Eq s, Eq a, Function a) => Lens' s a -> Property Source #

A Lens is only legal if it is a valid Traversal (see isTraversal for what this means), and if the following laws hold:

1. view l (set l b a)  ≡ b
2. set l (view l a) a  ≡ a
3. set l c (set l b a) ≡ set l c a

isTraversal :: (Arbitrary s, Arbitrary a, CoArbitrary a, Show s, Show a, Eq s, Function a) => Traversal' s a -> Property Source #

A Traversal is only legal if it is a valid Setter (see isSetter for what makes a Setter valid), and the following laws hold:

1. t pure ≡ pure
2. fmap (t f) . t g ≡ getCompose . t (Compose . fmap f . g)

isSetter :: (Arbitrary s, Arbitrary a, CoArbitrary a, Show s, Show a, Eq s, Function a) => Setter' s a -> Property Source #

A Setter is only legal if the following 3 laws hold:

1. set l y (set l x a) ≡ set l y a
2. over l id ≡ id
3. over l f . over l g ≡ over l (f . g)