From eca2e70a2eb2cfc26ce55d7eab326a24cd5bfd7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Justus=20Sagem=C3=BCller?= Date: Sun, 21 Apr 2019 16:22:47 +0200 Subject: [PATCH] QuickCheck instances for unit disks. --- manifolds/Data/Manifold/Types/Primitive.hs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/manifolds/Data/Manifold/Types/Primitive.hs b/manifolds/Data/Manifold/Types/Primitive.hs index b10fd47..53c97d2 100644 --- a/manifolds/Data/Manifold/Types/Primitive.hs +++ b/manifolds/Data/Manifold/Types/Primitive.hs @@ -259,6 +259,14 @@ instance QC.Arbitrary ℝP² where | θ' <- QC.shrink (θ*6/pi) , φ' <- QC.shrink (φ*12/pi) ] +instance QC.Arbitrary D¹ where + arbitrary = D¹ . (\x -> (x`mod'`2) - 1) <$> QC.arbitrary + shrink (D¹ p) = D¹ . (\x -> (x`mod'`2) - 1) <$> QC.shrink p +instance QC.Arbitrary D² where + arbitrary = D²Polar . (\x -> x`mod'`1) <$> QC.arbitrary + <*> (φParamS¹ <$> QC.arbitrary) + shrink (D²Polar r φ) = D²Polar . (\x -> (x`mod'`2) - 1) <$> QC.shrink r + <*> (φParamS¹ <$> QC.shrink (S¹Polar φ)) instance (SP.Show m, SP.Show f) => SP.Show (FibreBundle m f) where showsPrec p (FibreBundle m v) = showParen (p>9)