{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE ImportQualifiedPost #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# OPTIONS_GHC -Wno-orphans #-}

module Test.Cardano.Data.OMap.StrictSpec where

import Data.OMap.Strict
import Data.Proxy (Proxy (Proxy))
import Data.Sequence.Strict qualified as SSeq
import Data.Set qualified as Set
import Lens.Micro hiding (set)
import Test.Cardano.Data.Arbitrary ()
import Test.Cardano.Ledger.Binary.RoundTrip (roundTripCborSpec)
import Test.Hspec
import Test.Hspec.QuickCheck
import Test.QuickCheck (Arbitrary)
import Test.QuickCheck.Arbitrary (Arbitrary (arbitrary))
import Test.QuickCheck.Classes
import Prelude hiding (elem, filter, lookup, null)

spec :: Spec
spec :: Spec
spec =
  forall a. HasCallStack => String -> SpecWith a -> SpecWith a
describe String
"OMap.Strict" forall a b. (a -> b) -> a -> b
$ do
    forall a. HasCallStack => String -> SpecWith a -> SpecWith a
context String
"membership checks work" forall a b. (a -> b) -> a -> b
$ do
      forall prop.
(HasCallStack, Testable prop) =>
String -> prop -> Spec
prop String
"unconsed" forall a b. (a -> b) -> a -> b
$
        \(OMap Int Int
m :: OMap Int Int) -> case OMap Int Int
m of
          OMap Int Int
Empty -> forall (f :: * -> *) a. Applicative f => a -> f a
pure ()
          Int
v :<|: OMap Int Int
_kv -> Int
v forall s a. s -> Getting a s a -> a
^. forall k v. HasOKey k v => Lens' v k
okeyL forall a. (HasCallStack, Show a) => a -> (a -> Bool) -> IO ()
`shouldSatisfy` (forall k v. Ord k => k -> OMap k v -> Bool
`member` OMap Int Int
m)
      forall prop.
(HasCallStack, Testable prop) =>
String -> prop -> Spec
prop String
"unsnoced" forall a b. (a -> b) -> a -> b
$
        \(OMap Int Int
m :: OMap Int Int) -> case OMap Int Int
m of
          OMap Int Int
Empty -> forall (f :: * -> *) a. Applicative f => a -> f a
pure ()
          OMap Int Int
_kv :|>: Int
v -> Int
v forall s a. s -> Getting a s a -> a
^. forall k v. HasOKey k v => Lens' v k
okeyL forall a. (HasCallStack, Show a) => a -> (a -> Bool) -> IO ()
`shouldSatisfy` (forall k v. Ord k => k -> OMap k v -> Bool
`member` OMap Int Int
m)
    forall a. HasCallStack => String -> SpecWith a -> SpecWith a
context String
"when cons-ing" forall a b. (a -> b) -> a -> b
$ do
      forall prop.
(HasCallStack, Testable prop) =>
String -> prop -> Spec
prop String
"adding a duplicate results in a no-op" forall a b. (a -> b) -> a -> b
$
        \(OMap Int Int
m :: OMap Int Int) -> do
          case OMap Int Int
m of
            OMap Int Int
Empty -> forall (f :: * -> *) a. Applicative f => a -> f a
pure ()
            Int
v :<|: OMap Int Int
_kv -> OMap Int Int
m forall a. (HasCallStack, Show a, Eq a) => a -> a -> IO ()
`shouldBe` Int
v forall k v. HasOKey k v => v -> OMap k v -> OMap k v
<| OMap Int Int
m
          case OMap Int Int
m of
            OMap Int Int
Empty -> forall (f :: * -> *) a. Applicative f => a -> f a
pure ()
            OMap Int Int
_kv :|>: Int
v -> OMap Int Int
m forall a. (HasCallStack, Show a, Eq a) => a -> a -> IO ()
`shouldBe` Int
v forall k v. HasOKey k v => v -> OMap k v -> OMap k v
<| OMap Int Int
m
      forall prop.
(HasCallStack, Testable prop) =>
String -> prop -> Spec
prop String
"new values get added" forall a b. (a -> b) -> a -> b
$
        \((OMap Int Int
m, Int
v) :: (OMap Int Int, Int)) ->
          if Int
v forall k v. (HasOKey k v, Eq v) => v -> OMap k v -> Bool
`elem` OMap Int Int
m
            then Int
v forall k v. HasOKey k v => v -> OMap k v -> OMap k v
<| OMap Int Int
m forall a. (HasCallStack, Show a, Eq a) => a -> a -> IO ()
`shouldBe` OMap Int Int
m
            else Int
v forall k v. HasOKey k v => v -> OMap k v -> OMap k v
<| OMap Int Int
m forall a. (HasCallStack, Show a, Eq a) => a -> a -> IO ()
`shouldBe` Int
v forall k v. (HasOKey k v, Ord k) => v -> OMap k v -> OMap k v
:<|: OMap Int Int
m
    forall a. HasCallStack => String -> SpecWith a -> SpecWith a
context String
"when snoc-ing" forall a b. (a -> b) -> a -> b
$ do
      forall prop.
(HasCallStack, Testable prop) =>
String -> prop -> Spec
prop String
"adding a duplicate results in a no-op" forall a b. (a -> b) -> a -> b
$
        \(OMap Int Int
m :: OMap Int Int) -> do
          case OMap Int Int
m of
            OMap Int Int
Empty -> forall (f :: * -> *) a. Applicative f => a -> f a
pure ()
            Int
v :<|: OMap Int Int
_kv -> OMap Int Int
m forall a. (HasCallStack, Show a, Eq a) => a -> a -> IO ()
`shouldBe` OMap Int Int
m forall k v. HasOKey k v => OMap k v -> v -> OMap k v
|> Int
v
          case OMap Int Int
m of
            OMap Int Int
Empty -> forall (f :: * -> *) a. Applicative f => a -> f a
pure ()
            OMap Int Int
_kv :|>: Int
v -> OMap Int Int
m forall a. (HasCallStack, Show a, Eq a) => a -> a -> IO ()
`shouldBe` OMap Int Int
m forall k v. HasOKey k v => OMap k v -> v -> OMap k v
|> Int
v
      forall prop.
(HasCallStack, Testable prop) =>
String -> prop -> Spec
prop String
"new values get added" forall a b. (a -> b) -> a -> b
$
        \((OMap Int Int
m, Int
v) :: (OMap Int Int, Int)) ->
          if Int
v forall k v. (HasOKey k v, Eq v) => v -> OMap k v -> Bool
`elem` OMap Int Int
m
            then OMap Int Int
m forall k v. HasOKey k v => OMap k v -> v -> OMap k v
|> Int
v forall a. (HasCallStack, Show a, Eq a) => a -> a -> IO ()
`shouldBe` OMap Int Int
m
            else OMap Int Int
m forall k v. HasOKey k v => OMap k v -> v -> OMap k v
|> Int
v forall a. (HasCallStack, Show a, Eq a) => a -> a -> IO ()
`shouldBe` OMap Int Int
m forall k v. (HasOKey k v, Ord k) => OMap k v -> v -> OMap k v
:|>: Int
v
    forall a. HasCallStack => String -> SpecWith a -> SpecWith a
context String
"mappend preserves uniqueness" forall a b. (a -> b) -> a -> b
$ do
      forall prop.
(HasCallStack, Testable prop) =>
String -> prop -> Spec
prop String
"mappending with itself should be a no-op" forall a b. (a -> b) -> a -> b
$
        \(OMap Int Int
i :: OMap Int Int) -> do
          let il :: OMap Int Int
il = OMap Int Int
i forall k v. HasOKey k v => OMap k v -> OMap k v -> OMap k v
|>< OMap Int Int
i
              ir :: OMap Int Int
ir = OMap Int Int
i forall k v. HasOKey k v => OMap k v -> OMap k v -> OMap k v
><| OMap Int Int
i
          OMap Int Int
il forall a. (HasCallStack, Show a, Eq a) => a -> a -> IO ()
`shouldBe` OMap Int Int
i
          OMap Int Int
ir forall a. (HasCallStack, Show a, Eq a) => a -> a -> IO ()
`shouldBe` OMap Int Int
i
          OMap Int Int
il forall a. (HasCallStack, Show a) => a -> (a -> Bool) -> IO ()
`shouldSatisfy` forall k v. Ord k => OMap k v -> Bool
invariantHolds'
          OMap Int Int
ir forall a. (HasCallStack, Show a) => a -> (a -> Bool) -> IO ()
`shouldSatisfy` forall k v. Ord k => OMap k v -> Bool
invariantHolds'
      forall prop.
(HasCallStack, Testable prop) =>
String -> prop -> Spec
prop String
"mappending with duplicates: left-preserving" forall a b. (a -> b) -> a -> b
$
        \((OMap Int Int
i, OMap Int Int
j) :: (OMap Int Int, OMap Int Int)) ->
          case OMap Int Int
j of
            OMap Int Int
Empty -> OMap Int Int
i forall a. (HasCallStack, Show a, Eq a) => a -> a -> IO ()
`shouldBe` OMap Int Int
i forall k v. HasOKey k v => OMap k v -> OMap k v -> OMap k v
|>< OMap Int Int
j
            Int
j' :<|: OMap Int Int
_js -> do
              let result :: OMap Int Int
result = OMap Int Int
i forall k v. HasOKey k v => OMap k v -> OMap k v -> OMap k v
|>< OMap Int Int
j
              OMap Int Int
result forall a. (HasCallStack, Show a, Eq a) => a -> a -> IO ()
`shouldBe` (OMap Int Int
i forall k v. HasOKey k v => OMap k v -> v -> OMap k v
|> Int
j') forall k v. HasOKey k v => OMap k v -> OMap k v -> OMap k v
|>< OMap Int Int
j
              OMap Int Int
result forall a. (HasCallStack, Show a) => a -> (a -> Bool) -> IO ()
`shouldSatisfy` forall k v. Ord k => OMap k v -> Bool
invariantHolds'
      forall prop.
(HasCallStack, Testable prop) =>
String -> prop -> Spec
prop String
"mappending with duplicates: right-preserving" forall a b. (a -> b) -> a -> b
$
        \((OMap Int Int
i, OMap Int Int
j) :: (OMap Int Int, OMap Int Int)) ->
          case OMap Int Int
i of
            OMap Int Int
Empty -> OMap Int Int
i forall k v. HasOKey k v => OMap k v -> OMap k v -> OMap k v
><| OMap Int Int
j forall a. (HasCallStack, Show a, Eq a) => a -> a -> IO ()
`shouldBe` OMap Int Int
j
            OMap Int Int
_is :|>: Int
i' -> do
              let result :: OMap Int Int
result = OMap Int Int
i forall k v. HasOKey k v => OMap k v -> OMap k v -> OMap k v
><| OMap Int Int
j
              OMap Int Int
result forall a. (HasCallStack, Show a, Eq a) => a -> a -> IO ()
`shouldBe` OMap Int Int
i forall k v. HasOKey k v => OMap k v -> OMap k v -> OMap k v
><| (Int
i' forall k v. HasOKey k v => v -> OMap k v -> OMap k v
<| OMap Int Int
j)
              OMap Int Int
result forall a. (HasCallStack, Show a) => a -> (a -> Bool) -> IO ()
`shouldSatisfy` forall k v. Ord k => OMap k v -> Bool
invariantHolds'
    forall prop.
(HasCallStack, Testable prop) =>
String -> prop -> Spec
prop String
"extractKeys should satisfy membership" forall a b. (a -> b) -> a -> b
$
      \((OMap Int Int
omap, Set Int
set) :: (OMap Int Int, Set.Set Int)) -> do
        let result :: (OMap Int Int, Map Int Int)
result = forall k v. Ord k => Set k -> OMap k v -> (OMap k v, Map k v)
extractKeys Set Int
set OMap Int Int
omap
        (OMap Int Int, Map Int Int)
result forall a. (HasCallStack, Show a) => a -> (a -> Bool) -> IO ()
`shouldSatisfy` (forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
all (forall a. Ord a => a -> Set a -> Bool
`Set.notMember` Set Int
set) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. (a, b) -> a
fst)
        (OMap Int Int, Map Int Int)
result forall a. (HasCallStack, Show a) => a -> (a -> Bool) -> IO ()
`shouldSatisfy` (forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
all (forall a. Ord a => a -> Set a -> Bool
`Set.member` Set Int
set) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. (a, b) -> b
snd)
        (OMap Int Int, Map Int Int)
result forall a. (HasCallStack, Show a) => a -> (a -> Bool) -> IO ()
`shouldSatisfy` forall k v. Ord k => OMap k v -> Bool
invariantHolds' forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. (a, b) -> a
fst
    forall prop.
(HasCallStack, Testable prop) =>
String -> prop -> Spec
prop String
"filter" forall a b. (a -> b) -> a -> b
$
      \((OMap Int Int
omap, Int
i) :: (OMap Int Int, Int)) -> do
        let result :: OMap Int Int
result = forall k v. Ord k => (v -> Bool) -> OMap k v -> OMap k v
filter (forall a. Ord a => a -> a -> Bool
< Int
i) OMap Int Int
omap
        OMap Int Int
result forall a. (HasCallStack, Show a) => a -> (a -> Bool) -> IO ()
`shouldSatisfy` forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
all (forall a. Ord a => a -> a -> Bool
< Int
i)
        OMap Int Int
result forall a. (HasCallStack, Show a) => a -> (a -> Bool) -> IO ()
`shouldSatisfy` forall k v. Ord k => OMap k v -> Bool
invariantHolds'
    forall prop.
(HasCallStack, Testable prop) =>
String -> prop -> Spec
prop String
"adjust" forall a b. (a -> b) -> a -> b
$
      \((OMap Int OMapTest
omap, Int
i) :: (OMap Int OMapTest, Int)) -> do
        let adjustingFn :: OMapTest -> OMapTest
adjustingFn omt :: OMapTest
omt@OMapTest {Int
omSnd :: OMapTest -> Int
omSnd :: Int
omSnd} = OMapTest
omt {omSnd :: Int
omSnd = Int
omSnd forall a. Num a => a -> a -> a
+ Int
1}
            overwritingAdjustingFn :: OMapTest -> OMapTest
overwritingAdjustingFn omt :: OMapTest
omt@OMapTest {Int
omFst :: OMapTest -> Int
omFst :: Int
omFst} = OMapTest
omt {omFst :: Int
omFst = Int
omFst forall a. Num a => a -> a -> a
+ Int
1} -- Changes the `okeyL`.
        forall k v. HasOKey k v => (v -> v) -> k -> OMap k v -> OMap k v
adjust OMapTest -> OMapTest
adjustingFn Int
i OMap Int OMapTest
omap forall a. (HasCallStack, Show a) => a -> (a -> Bool) -> IO ()
`shouldSatisfy` forall k v. Ord k => OMap k v -> Bool
invariantHolds'
        forall k v. HasOKey k v => (v -> v) -> k -> OMap k v -> OMap k v
adjust OMapTest -> OMapTest
overwritingAdjustingFn Int
i OMap Int OMapTest
omap forall a. (HasCallStack, Show a) => a -> (a -> Bool) -> IO ()
`shouldSatisfy` forall k v. Ord k => OMap k v -> Bool
invariantHolds'
    forall a. HasCallStack => String -> SpecWith a -> SpecWith a
context String
"overwriting" forall a b. (a -> b) -> a -> b
$ do
      forall prop.
(HasCallStack, Testable prop) =>
String -> prop -> Spec
prop String
"cons' - (<||)" forall a b. (a -> b) -> a -> b
$
        \((OMap Int OMapTest
omap, OMapTest
i) :: (OMap Int OMapTest, OMapTest)) -> do
          let consed :: OMap Int OMapTest
consed = OMapTest
i forall k v. HasOKey k v => v -> OMap k v -> OMap k v
<|| OMap Int OMapTest
omap
              k :: Int
k = OMapTest
i forall s a. s -> Getting a s a -> a
^. forall k v. HasOKey k v => Lens' v k
okeyL
          if Int
k forall k v. Ord k => k -> OMap k v -> Bool
`member` OMap Int OMapTest
omap
            then OMap Int OMapTest
consed forall a. (HasCallStack, Show a, Eq a) => a -> a -> IO ()
`shouldBe` forall k v. HasOKey k v => (v -> v) -> k -> OMap k v -> OMap k v
adjust (forall a b. a -> b -> a
const OMapTest
i) (OMapTest
i forall s a. s -> Getting a s a -> a
^. forall k v. HasOKey k v => Lens' v k
okeyL) OMap Int OMapTest
omap
            else OMap Int OMapTest
consed forall a. (HasCallStack, Show a, Eq a) => a -> a -> IO ()
`shouldBe` OMapTest
i forall k v. HasOKey k v => v -> OMap k v -> OMap k v
<| OMap Int OMapTest
omap
      forall prop.
(HasCallStack, Testable prop) =>
String -> prop -> Spec
prop String
"snoc' - (||>)" forall a b. (a -> b) -> a -> b
$
        \((OMap Int OMapTest
omap, OMapTest
i) :: (OMap Int OMapTest, OMapTest)) -> do
          let snoced :: OMap Int OMapTest
snoced = OMap Int OMapTest
omap forall k v. HasOKey k v => OMap k v -> v -> OMap k v
||> OMapTest
i
              k :: Int
k = OMapTest
i forall s a. s -> Getting a s a -> a
^. forall k v. HasOKey k v => Lens' v k
okeyL
          if Int
k forall k v. Ord k => k -> OMap k v -> Bool
`member` OMap Int OMapTest
omap
            then OMap Int OMapTest
snoced forall a. (HasCallStack, Show a, Eq a) => a -> a -> IO ()
`shouldBe` forall k v. HasOKey k v => (v -> v) -> k -> OMap k v -> OMap k v
adjust (forall a b. a -> b -> a
const OMapTest
i) (OMapTest
i forall s a. s -> Getting a s a -> a
^. forall k v. HasOKey k v => Lens' v k
okeyL) OMap Int OMapTest
omap
            else OMap Int OMapTest
snoced forall a. (HasCallStack, Show a, Eq a) => a -> a -> IO ()
`shouldBe` OMap Int OMapTest
omap forall k v. HasOKey k v => OMap k v -> v -> OMap k v
|> OMapTest
i
    forall prop.
(HasCallStack, Testable prop) =>
String -> prop -> Spec
prop String
"fromFoldable preserves order" forall a b. (a -> b) -> a -> b
$
      \(Set Int
set :: Set.Set Int) -> do
        let sseq :: StrictSeq Int
sseq = forall a. [a] -> StrictSeq a
SSeq.fromList forall a b. (a -> b) -> a -> b
$ forall a. Set a -> [a]
Set.elems Set Int
set
            omap :: OMap Int Int
omap = forall (f :: * -> *) k v.
(Foldable f, HasOKey k v) =>
f v -> OMap k v
fromFoldable StrictSeq Int
sseq
        forall k v. Ord k => OMap k v -> StrictSeq v
toStrictSeq OMap Int Int
omap forall a. (HasCallStack, Show a, Eq a) => a -> a -> IO ()
`shouldBe` StrictSeq Int
sseq
        OMap Int Int
omap forall a. (HasCallStack, Show a) => a -> (a -> Bool) -> IO ()
`shouldSatisfy` forall k v. Ord k => OMap k v -> Bool
invariantHolds'
    forall a. HasCallStack => String -> SpecWith a -> SpecWith a
context String
"fromFoldableDuplicates preserves order" forall a b. (a -> b) -> a -> b
$ do
      forall prop.
(HasCallStack, Testable prop) =>
String -> prop -> Spec
prop String
"with duplicates" forall a b. (a -> b) -> a -> b
$
        \(Set Int
set :: Set.Set Int) -> do
          let sseq :: StrictSeq Int
sseq = forall a. [a] -> StrictSeq a
SSeq.fromList forall a b. (a -> b) -> a -> b
$ forall a. Set a -> [a]
Set.elems Set Int
set
              omap :: OMap Int Int
omap = forall (f :: * -> *) k v.
(Foldable f, HasOKey k v) =>
f v -> OMap k v
fromFoldable StrictSeq Int
sseq
              result :: (Set Int, OMap Int Int)
result = forall (f :: * -> *) k v.
(Foldable f, HasOKey k v, Ord v) =>
f v -> (Set v, OMap k v)
fromFoldableDuplicates (StrictSeq Int
sseq forall a. StrictSeq a -> StrictSeq a -> StrictSeq a
SSeq.>< StrictSeq Int
sseq)
          forall k v. Ord k => OMap k v -> StrictSeq v
toStrictSeq (forall a b. (a, b) -> b
snd (Set Int, OMap Int Int)
result) forall a. (HasCallStack, Show a, Eq a) => a -> a -> IO ()
`shouldBe` StrictSeq Int
sseq
          (Set Int, OMap Int Int)
result forall a. (HasCallStack, Show a, Eq a) => a -> a -> IO ()
`shouldBe` (Set Int
set, OMap Int Int
omap)
          forall a b. (a, b) -> b
snd (Set Int, OMap Int Int)
result forall a. (HasCallStack, Show a) => a -> (a -> Bool) -> IO ()
`shouldSatisfy` forall k v. Ord k => OMap k v -> Bool
invariantHolds'
      forall prop.
(HasCallStack, Testable prop) =>
String -> prop -> Spec
prop String
"without duplicates" forall a b. (a -> b) -> a -> b
$
        \(Set Int
set :: Set.Set Int) -> do
          let sseq :: StrictSeq Int
sseq = forall a. [a] -> StrictSeq a
SSeq.fromList forall a b. (a -> b) -> a -> b
$ forall a. Set a -> [a]
Set.elems Set Int
set
              omap :: OMap Int Int
omap = forall (f :: * -> *) k v.
(Foldable f, HasOKey k v) =>
f v -> OMap k v
fromFoldable StrictSeq Int
sseq
              result :: (Set Int, OMap Int Int)
result = forall (f :: * -> *) k v.
(Foldable f, HasOKey k v, Ord v) =>
f v -> (Set v, OMap k v)
fromFoldableDuplicates StrictSeq Int
sseq
          forall k v. Ord k => OMap k v -> StrictSeq v
toStrictSeq (forall a b. (a, b) -> b
snd (Set Int, OMap Int Int)
result) forall a. (HasCallStack, Show a, Eq a) => a -> a -> IO ()
`shouldBe` StrictSeq Int
sseq
          (Set Int, OMap Int Int)
result forall a. (HasCallStack, Show a, Eq a) => a -> a -> IO ()
`shouldBe` (forall a. Set a
Set.empty, OMap Int Int
omap)
          forall a b. (a, b) -> b
snd (Set Int, OMap Int Int)
result forall a. (HasCallStack, Show a) => a -> (a -> Bool) -> IO ()
`shouldSatisfy` forall k v. Ord k => OMap k v -> Bool
invariantHolds'
    forall a. HasCallStack => String -> SpecWith a -> SpecWith a
context String
"CBOR round-trip" forall a b. (a -> b) -> a -> b
$ do
      forall t. (Show t, Eq t, Arbitrary t, EncCBOR t, DecCBOR t) => Spec
roundTripCborSpec @(OMap Int Int)
    forall a. HasCallStack => String -> SpecWith a -> SpecWith a
context String
"Typeclass laws" forall a b. (a -> b) -> a -> b
$ do
      forall a.
(HasCallStack, Example a) =>
String -> a -> SpecWith (Arg a)
it String
"Type" forall a b. (a -> b) -> a -> b
$
        forall a. Proxy a -> [Proxy a -> Laws] -> IO ()
lawsCheckOne
          (forall {k} (t :: k). Proxy t
Proxy :: Proxy (OMap Int Int))
          [ forall a. (Eq a, Arbitrary a, Show a) => Proxy a -> Laws
eqLaws
          , forall a.
(IsList a, Show a, Show (Item a), Arbitrary a, Arbitrary (Item a),
 Eq a) =>
Proxy a -> Laws
isListLaws
          , forall a.
(Semigroup a, Eq a, Arbitrary a, Show a) =>
Proxy a -> Laws
semigroupLaws
          , forall a. (Monoid a, Eq a, Arbitrary a, Show a) => Proxy a -> Laws
monoidLaws
          , forall a.
(Semigroup a, Monoid a, Eq a, Arbitrary a, Show a) =>
Proxy a -> Laws
semigroupMonoidLaws
          ]

instance HasOKey Int Int where
  okeyL :: Lens' Int Int
okeyL = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens forall a. a -> a
id forall a b. a -> b -> a
const

data OMapTest = OMapTest {OMapTest -> Int
omFst :: Int, OMapTest -> Int
omSnd :: Int}
  deriving (OMapTest -> OMapTest -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: OMapTest -> OMapTest -> Bool
$c/= :: OMapTest -> OMapTest -> Bool
== :: OMapTest -> OMapTest -> Bool
$c== :: OMapTest -> OMapTest -> Bool
Eq, Int -> OMapTest -> ShowS
[OMapTest] -> ShowS
OMapTest -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [OMapTest] -> ShowS
$cshowList :: [OMapTest] -> ShowS
show :: OMapTest -> String
$cshow :: OMapTest -> String
showsPrec :: Int -> OMapTest -> ShowS
$cshowsPrec :: Int -> OMapTest -> ShowS
Show, Eq OMapTest
OMapTest -> OMapTest -> Bool
OMapTest -> OMapTest -> Ordering
OMapTest -> OMapTest -> OMapTest
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: OMapTest -> OMapTest -> OMapTest
$cmin :: OMapTest -> OMapTest -> OMapTest
max :: OMapTest -> OMapTest -> OMapTest
$cmax :: OMapTest -> OMapTest -> OMapTest
>= :: OMapTest -> OMapTest -> Bool
$c>= :: OMapTest -> OMapTest -> Bool
> :: OMapTest -> OMapTest -> Bool
$c> :: OMapTest -> OMapTest -> Bool
<= :: OMapTest -> OMapTest -> Bool
$c<= :: OMapTest -> OMapTest -> Bool
< :: OMapTest -> OMapTest -> Bool
$c< :: OMapTest -> OMapTest -> Bool
compare :: OMapTest -> OMapTest -> Ordering
$ccompare :: OMapTest -> OMapTest -> Ordering
Ord)

instance HasOKey Int OMapTest where
  okeyL :: Lens' OMapTest Int
okeyL = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens OMapTest -> Int
omFst forall a b. (a -> b) -> a -> b
$ \OMapTest
om Int
u -> OMapTest
om {omFst :: Int
omFst = Int
u}

instance Arbitrary OMapTest where
  arbitrary :: Gen OMapTest
arbitrary = Int -> Int -> OMapTest
OMapTest forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a. Arbitrary a => Gen a
arbitrary forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. Arbitrary a => Gen a
arbitrary