Skip to content

Instantly share code, notes, and snippets.

@PkmX
Last active March 6, 2017 08:33
Show Gist options
  • Save PkmX/bc72ab799e09127448d0a043d2840f2a to your computer and use it in GitHub Desktop.
Save PkmX/bc72ab799e09127448d0a043d2840f2a to your computer and use it in GitHub Desktop.
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE ScopedTypeVariables #-}
module Main where
import Data.Reflection
newtype QDouble = QDouble Double
newtype Step = Step Double
instance Given Step => Eq QDouble where
QDouble x == QDouble y = abs (x - y) < s
where Step s = given
main :: IO ()
main = do
n :: Double <- read <$> getLine
print $ give (Step n) $ QDouble 0.5 == QDouble 0.6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment