-- FlexibleInstances is needed for OverlappingInstances to be used -- meaningfully. {-# LANGUAGE CPP , ForeignFunctionInterface , OverlappingInstances , FlexibleInstances #-} ---------------------------------------------------------------- -- ~ 2009.03.17 -- | -- Module : Cabal.FFIHugsTest -- Copyright : Copyright (c) 2009 wren ng thornton -- License : BSD3 -- Maintainer : wren@community.haskell.org -- Stability : provisional -- Portability : semi-portable (CPP, FFI, OverlappingInstances) -- -- This package is a minimal regression suite for debugging Cabal's -- interaction with ffihugs when building for Hugs. This suite fails -- under Cabal-1.2.3.0 with Hugs-September2006, and is believed to -- fail under Cabal 1.6 as well. There are two distinct bugs, see -- the README file for more details. -- -- * <http://hackage.haskell.org/trac/hackage/ticket/526> -- -- * <http://hackage.haskell.org/trac/hackage/ticket/527> ---------------------------------------------------------------- module Cabal.FFIHugsTest ( Class(..) , logarithm ) where -- | Requires OverlappingInstances and FlexibleInstances. Thus, +o -- and -98 (respectively) should be used in both hugs and ffihugs. class Class a where classy :: a -> a -- For debugging the debugging instance Class Bool where classy = const False -- For making the next two really overlap instance Class Int where classy = const 1 instance Class a => Class (Maybe a) where classy (Just a) = Just (classy a) classy Nothing = Nothing instance Class (Maybe Int) where classy (Just _) = Just 0 classy Nothing = Nothing -- | Requires CPP and FFI. Thus cpp/cpphs should be run before -- ffihugs. #ifdef __USE_FFI__ foreign import ccall unsafe "math.h log" logarithm :: Double -> Double #else logarithm :: Double -> Double logarithm = log #endif -- | This is just for debugging that Cabal's -D__HUGS__ doesn't -- override our own -D__HUGS__=200609. (Which is correct in -- Cabal-1.2.3.0.) hugsVersion :: String #if defined(__HUGS__) # if __HUGS__ > 0 hugsVersion = "Greater than 0" # else hugsVersion = "Is 0" # endif #else hugsVersion = "Not Hugs" #endif