Skip to content

Instantly share code, notes, and snippets.

@alios
Created July 30, 2011 09:11
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save alios/1115357 to your computer and use it in GitHub Desktop.
ghc-7.0.4 linux i386
{-# LANGUAGE TemplateHaskell, FlexibleInstances #-}
import Test.QuickCheck
import Test.QuickCheck.All
instance (Bounded a, Enum a, Num a) => Eq (a -> a) where
f1 == f2 = and [f1 x == f2 x | x <- [minBound .. maxBound]]
t1, t2, t3 :: Int
t1 x = x * x
t2 x = (x-1)*(x+1)+1
t3 x = (x-2)*(x+2)+4
prop_x1 x = t1 x == t2 x
prop_x2 x = t2 x == t3 x
prop_x3 x = t1 x == t3 x
runTests = $quickCheckAll
{-
Fails here in ghci session with
:load "/home/alios/tmp/foo.hs"
GHCi, version 7.0.4: http://www.haskell.org/ghc/ :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Loading package ffi-1.0 ... linking ... done.
Prelude> [1 of 1] Compiling Main ( /home/alios/tmp/foo.hs, interpreted )
Loading package pretty-1.0.1.2 ... linking ... done.
Loading package extensible-exceptions-0.1.1.2 ... linking ... done.
Loading package old-locale-1.0.0.2 ... linking ... done.
Loading package time-1.2.0.3 ... linking ... done.
Loading package random-1.0.0.3 ... linking ... done.
Loading package array-0.3.0.2 ... linking ... done.
Loading package containers-0.4.0.0 ... linking ... done.
Loading package template-haskell ... linking ... done.
Loading package QuickCheck-2.4.1.1 ... linking ... done.
/home/alios/tmp/foo.hs:11:1:
The equation(s) for `t1' have one argument,
but its type `Int' has none
/home/alios/tmp/foo.hs:12:1:
The equation(s) for `t2' have one argument,
but its type `Int' has none
/home/alios/tmp/foo.hs:13:1:
The equation(s) for `t3' have one argument,
but its type `Int' has none
/home/alios/tmp/foo.hs:15:13:
The function `t1' is applied to one argument,
but its type `Int' has none
In the first argument of `(==)', namely `t1 x'
In the expression: t1 x == t2 x
In an equation for `prop_x1': prop_x1 x = t1 x == t2 x
/home/alios/tmp/foo.hs:16:13:
The function `t2' is applied to one argument,
but its type `Int' has none
In the first argument of `(==)', namely `t2 x'
In the expression: t2 x == t3 x
In an equation for `prop_x2': prop_x2 x = t2 x == t3 x
/home/alios/tmp/foo.hs:17:13:
The function `t1' is applied to one argument,
but its type `Int' has none
In the first argument of `(==)', namely `t1 x'
In the expression: t1 x == t3 x
In an equation for `prop_x3': prop_x3 x = t1 x == t3 x
/home/alios/tmp/foo.hs:19:12:ghc: panic! (the 'impossible' happened)
(GHC version 7.0.4 for i386-unknown-linux):
Exotic form of kind ghc-prim:GHC.Prim.?{(w) tc 34g}
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
-}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment