From 5d956a3d897deed54b4578fb59aa5b4d2392eaa3 Mon Sep 17 00:00:00 2001 From: Simon Bruder Date: Tue, 27 Dec 2022 20:01:09 +0100 Subject: [PATCH] Implement Arbitrary for Vertex --- genstar/Main.hs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/genstar/Main.hs b/genstar/Main.hs index 6ce945f..fedd766 100644 --- a/genstar/Main.hs +++ b/genstar/Main.hs @@ -1,6 +1,7 @@ module Main where import Control.Monad (join) +import Test.QuickCheck (Arbitrary (arbitrary)) -- | One point of a path, consisting of its \(x\) and \(y\) coordinates. newtype Vertex = Point (Double, Double) @@ -8,6 +9,12 @@ newtype Vertex = Point (Double, Double) instance Show Vertex where show (Point (x, y)) = show x ++ " " ++ show y +instance Arbitrary Vertex where + arbitrary = do + x <- arbitrary + y <- arbitrary + return (Point (x, y)) + -- | 'fromAngle' @angle@ -- creats a point on the unit circle at the specified angle -- (specified in radians).