id summary reporter owner description type status priority milestone component version resolution keywords cc os architecture failure difficulty testcase blockedby blocking related
963 monadic Num instance not found in ghci rwxr-xr-x@… "Here's my code (fun.hs):
{{{
{-# OPTIONS_GHC -fglasgow-exts -fallow-undecidable-instances #-}
import Control.Monad.Reader
instance Eq (a -> b) where
_ == _ = error ""whoops""
instance Show (a -> b) where
show = const """"
instance (Num a, Monad m, Eq (m a), Show (m a)) => Num (m a) where
fromInteger = return . fromInteger
abs = liftM abs
signum = liftM signum
(+) = liftM2 (+)
(*) = liftM2 (*)
(-) = liftM2 (-)
instance (Fractional a, Monad m, Num (m a)) => Fractional (m a) where
fromRational = return . fromRational
(/) = liftM2 (/)
instance (Floating a, Monad m, Fractional (m a)) => Floating (m a) where
pi = return pi
exp = liftM exp
log = liftM log
sin = liftM sin
cos = liftM cos
tan = liftM tan
sinh = liftM sinh
cosh = liftM cosh
tanh = liftM tanh
asin = liftM sin
acos = liftM cos
atan = liftM tan
asinh = liftM sinh
acosh = liftM cosh
atanh = liftM tanh
}}}
Test session:
{{{
$ ghci fun.hs
___ ___ _
/ _ \ /\ /\/ __(_)
/ /_\// /_/ / / | | GHC Interactive, version 6.6, for Haskell 98.
/ /_\\/ __ / /___| | http://www.haskell.org/ghc/
\____/\/ /_/\____/|_| Type :? for help.
Loading package base ... linking ... done.
[1 of 1] Compiling Main ( fun.hs, interpreted )
Ok, modules loaded: Main.
*Main> 1 2
:1:0:
No instance for (Num (t1 -> t))
arising from the literal `1' at :1:0-2
Possible fix: add an instance declaration for (Num (t1 -> t))
In the expression: 1 2
In the definition of `it': it = 1 2
}}}
Expected result:
{{{
Loading package mtl-1.0 ... linking ... done.
1
}}}
This used to work in ghci-6.4. What's also weird is that manually lifting
one number seems to help:
{{{
*Main> (1 + 2) undefined
:1:1:
No instance for (Num (a -> t))
arising from the literal `1' at :1:1
Possible fix: add an instance declaration for (Num (a -> t))
In the first argument of `(+)', namely `1'
In the expression: (1 + 2) undefined
In the definition of `it': it = (1 + 2) undefined
*Main> (1 + const 2) undefined
3
}}}" bug closed normal GHCi 6.6 fixed Linux x86 Unknown tc217