Commit 28ac9d31 authored by Simon Peyton Jones's avatar Simon Peyton Jones Committed by Ben Gamari

Improve the error messages for class instance errors

Summary: See Note [Displaying potential instances].

Reviewers: austin

Subscribers: KaneTW, thomie

Differential Revision: https://phabricator.haskell.org/D1176
parent c8f623e3
......@@ -338,6 +338,7 @@ data GeneralFlag
| Opt_PrintExplicitKinds
| Opt_PrintUnicodeSyntax
| Opt_PrintExpandedSynonyms
| Opt_PrintPotentialInstances
-- optimisation opts
| Opt_CallArity
......@@ -3014,6 +3015,7 @@ fFlags = [
flagSpec "print-explicit-kinds" Opt_PrintExplicitKinds,
flagSpec "print-unicode-syntax" Opt_PrintUnicodeSyntax,
flagSpec "print-expanded-synonyms" Opt_PrintExpandedSynonyms,
flagSpec "print-potential-instances" Opt_PrintPotentialInstances,
flagSpec "prof-cafs" Opt_AutoSccsOnIndividualCafs,
flagSpec "prof-count-entries" Opt_ProfCountEntries,
flagSpec "regs-graph" Opt_RegsGraph,
......
......@@ -33,6 +33,7 @@ import Id
import Var
import VarSet
import VarEnv
import NameSet
import Bag
import ErrUtils ( ErrMsg, pprLocErrMsg )
import BasicTypes
......@@ -1530,10 +1531,9 @@ mk_dict_err ctxt (ct, (matches, unifiers, unsafe_overlapped))
potential_msg
= ppWhen (not (null unifiers) && want_potential orig) $
hang (if isSingleton unifiers
then ptext (sLit "Note: there is a potential instance available:")
else ptext (sLit "Note: there are several potential instances:"))
2 (ppr_insts (sortBy fuzzyClsInstCmp unifiers))
sdocWithDynFlags $ \dflags ->
getPprStyle $ \sty ->
pprPotentials dflags sty (ptext (sLit "Potential instances:")) unifiers
-- Report "potential instances" only when the constraint arises
-- directly from the user's use of an overloaded function
......@@ -1587,8 +1587,10 @@ mk_dict_err ctxt (ct, (matches, unifiers, unsafe_overlapped))
sep [ptext (sLit "Matching givens (or their superclasses):")
, nest 2 (vcat matching_givens)]
, sep [ptext (sLit "Matching instances:"),
nest 2 (vcat [pprInstances ispecs, pprInstances unifiers])]
, sdocWithDynFlags $ \dflags ->
getPprStyle $ \sty ->
pprPotentials dflags sty (ptext (sLit "Matching instances:")) $
ispecs ++ unifiers
, ppWhen (null matching_givens && isSingleton matches && null unifiers) $
-- Intuitively, some given matched the wanted in their
......@@ -1670,17 +1672,86 @@ show_fixes [] = empty
show_fixes (f:fs) = sep [ ptext (sLit "Possible fix:")
, nest 2 (vcat (f : map (ptext (sLit "or") <+>) fs))]
ppr_insts :: [ClsInst] -> SDoc
ppr_insts insts
= pprInstances (take 3 insts) $$ dot_dot_message
pprPotentials :: DynFlags -> PprStyle -> SDoc -> [ClsInst] -> SDoc
-- See Note [Displaying potential instances]
pprPotentials dflags sty herald insts
| null insts
= empty
| null show_these
= hang herald
2 (vcat [ not_in_scope_msg empty
, flag_hint ])
| otherwise
= hang herald
2 (vcat [ pprInstances show_these
, ppWhen (n_in_scope_hidden > 0) $
ptext (sLit "...plus")
<+> speakNOf n_in_scope_hidden (ptext (sLit "other"))
, not_in_scope_msg (ptext (sLit "...plus"))
, flag_hint ])
where
n_extra = length insts - 3
dot_dot_message
| n_extra <= 0 = empty
| otherwise = ptext (sLit "...plus")
<+> speakNOf n_extra (ptext (sLit "other"))
n_show = 3 :: Int
show_potentials = gopt Opt_PrintPotentialInstances dflags
(in_scope, not_in_scope) = partition inst_in_scope insts
sorted = sortBy fuzzyClsInstCmp in_scope
show_these | show_potentials = sorted
| otherwise = take n_show sorted
n_in_scope_hidden = length sorted - length show_these
-- "in scope" means that all the type constructors
-- are lexically in scope; these instances are likely
-- to be more useful
inst_in_scope :: ClsInst -> Bool
inst_in_scope cls_inst = foldNameSet ((&&) . name_in_scope) True $
orphNamesOfTypes (is_tys cls_inst)
name_in_scope name
| isBuiltInSyntax name
= True -- E.g. (->)
| Just mod <- nameModule_maybe name
= qual_in_scope (qualName sty mod (nameOccName name))
| otherwise
= True
qual_in_scope :: QualifyName -> Bool
qual_in_scope NameUnqual = True
qual_in_scope (NameQual {}) = True
qual_in_scope _ = False
not_in_scope_msg herald
| null not_in_scope
= empty
| otherwise
= hang (herald <+> speakNOf (length not_in_scope)
(ptext (sLit "instance involving out-of-scope types")))
2 (ppWhen show_potentials (pprInstances not_in_scope))
flag_hint = ppUnless (show_potentials || length show_these == length insts) $
ptext (sLit "(use -fprint-potential-instances to see them all)")
{- Note [Displaying potential instances]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
When showing a list of instances for
- overlapping instances (show ones that match)
- no such instance (show ones that could match)
we want to give it a bit of structure. Here's the plan
* Say that an instance is "in scope" if all of the
type constructors it mentions are lexically in scope.
These are the ones most likely to be useful to the programmer.
* Show at most n_show in-scope instances,
and summarise the rest ("plus 3 others")
* Summarise the not-in-scope instances ("plus 4 not in scope")
* Add the flag -fshow-potential-instances which replaces the
summary with the full list
-}
----------------------
quickFlattenTy :: TcType -> TcM TcType
-- See Note [Flattening in error message generation]
quickFlattenTy ty | Just ty' <- tcView ty = quickFlattenTy ty'
......@@ -1705,9 +1776,8 @@ quickFlattenTy (TyConApp tc tys)
; flat_resttys <- mapM quickFlattenTy resttys
; return (foldl AppTy (mkTyVarTy v) flat_resttys) }
{-
Note [Flattening in error message generation]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
{- Note [Flattening in error message generation]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Consider (C (Maybe (F x))), where F is a type function, and we have
instances
C (Maybe Int) and C (Maybe a)
......
......@@ -35,6 +35,12 @@
<entry>dynamic</entry>
<entry>-</entry>
</row>
<row>
<entry><option>-fprint-potential-instances</option></entry>
<entry>display all available instances in type error messages</entry>
<entry>dynamic</entry>
<entry>-fno-print-potential-instances</entry>
</row>
<row>
<entry><option>-fprint-explicit-foralls</option></entry>
<entry>Print explicit <literal>forall</literal> quantification in types. See also <option>-XExplicitForAll</option></entry>
......
......@@ -894,6 +894,16 @@ ghc -c Foo.hs
</listitem>
</varlistentry>
<varlistentry>
<term><option>--fprint-potential-instances</option>
<indexterm><primary><option>-fprint-potential-instances</option></primary></indexterm>
</term>
<listitem>
<para>When GHC can't find an instance for a class, it displays a short list of some
in the instances it knows about. With this flag it prints <emphasis>all</emphasis>
the instances it knows about.
</para></listitem>
</varlistentry>
<varlistentry>
<term><option>-fprint-explicit-foralls, -fprint-explicit-kinds, -fprint-unicode-syntax</option>
......
annfail10.hs:9:1:
No instance for (Data a0) arising from an annotation
The type variable ‘a0’ is ambiguous
Note: there are several potential instances:
instance (Data a, Data b) => Data (Either a b)
-- Defined in ‘Data.Data’
instance Data All -- Defined in ‘Data.Data’
instance (Data (f a), Data a, Typeable f) => Data (Alt f a)
-- Defined in ‘Data.Data’
...plus 39 others
In the annotation: {-# ANN f 1 #-}
annfail10.hs:9:11:
No instance for (Num a0) arising from the literal ‘1’
The type variable ‘a0’ is ambiguous
Note: there are several potential instances:
instance forall (k :: BOX) (f :: k -> *) (a :: k).
Num (f a) =>
Num (Alt f a)
-- Defined in ‘Data.Monoid’
instance Num a => Num (Product a) -- Defined in ‘Data.Monoid’
instance Num a => Num (Sum a) -- Defined in ‘Data.Monoid’
...plus 14 others
In the annotation: {-# ANN f 1 #-}
annfail10.hs:9:1: error:
No instance for (Data a0) arising from an annotation
The type variable ‘a0’ is ambiguous
Potential instances:
instance (Data a, Data b) => Data (Either a b)
-- Defined in ‘Data.Data’
instance Data All -- Defined in ‘Data.Data’
instance (Data (f a), Data a, Typeable f) => Data (Alt f a)
-- Defined in ‘Data.Data’
...plus 39 others
(use -fprint-potential-instances to see them all)
In the annotation: {-# ANN f 1 #-}
annfail10.hs:9:11: error:
No instance for (Num a0) arising from the literal ‘1’
The type variable ‘a0’ is ambiguous
Potential instances:
instance forall (k :: BOX) (f :: k -> *) (a :: k).
Num (f a) =>
Num (Alt f a)
-- Defined in ‘Data.Monoid’
instance Num a => Num (Product a) -- Defined in ‘Data.Monoid’
instance Num a => Num (Sum a) -- Defined in ‘Data.Monoid’
...plus 14 others
(use -fprint-potential-instances to see them all)
In the annotation: {-# ANN f 1 #-}
<interactive>:5:1:
No instance for (Show t1) arising from a use of ‘print’
Cannot resolve unknown runtime type ‘t1’
Use :print or :force to determine these types
Relevant bindings include it :: t1 (bound at <interactive>:5:1)
Note: there are several potential instances:
instance (Show a, Show b) => Show (Either a b)
-- Defined in ‘Data.Either’
instance Show All -- Defined in ‘Data.Monoid’
instance forall (k :: BOX) (f :: k -> *) (a :: k).
Show (f a) =>
Show (Alt f a)
-- Defined in ‘Data.Monoid’
...plus 33 others
In a stmt of an interactive GHCi command: print it
<interactive>:7:1:
No instance for (Show t1) arising from a use of ‘print’
Cannot resolve unknown runtime type ‘t1’
Use :print or :force to determine these types
Relevant bindings include it :: t1 (bound at <interactive>:7:1)
Note: there are several potential instances:
instance (Show a, Show b) => Show (Either a b)
-- Defined in ‘Data.Either’
instance Show All -- Defined in ‘Data.Monoid’
instance forall (k :: BOX) (f :: k -> *) (a :: k).
Show (f a) =>
Show (Alt f a)
-- Defined in ‘Data.Monoid’
...plus 33 others
In a stmt of an interactive GHCi command: print it
<interactive>:5:1: error:
No instance for (Show t1) arising from a use of ‘print’
Cannot resolve unknown runtime type ‘t1’
Use :print or :force to determine these types
Relevant bindings include it :: t1 (bound at <interactive>:5:1)
Potential instances:
instance (Show a, Show b) => Show (Either a b)
-- Defined in ‘Data.Either’
instance Show All -- Defined in ‘Data.Monoid’
instance forall (k :: BOX) (f :: k -> *) (a :: k).
Show (f a) =>
Show (Alt f a)
-- Defined in ‘Data.Monoid’
...plus 33 others
(use -fprint-potential-instances to see them all)
In a stmt of an interactive GHCi command: print it
<interactive>:7:1: error:
No instance for (Show t1) arising from a use of ‘print’
Cannot resolve unknown runtime type ‘t1’
Use :print or :force to determine these types
Relevant bindings include it :: t1 (bound at <interactive>:7:1)
Potential instances:
instance (Show a, Show b) => Show (Either a b)
-- Defined in ‘Data.Either’
instance Show All -- Defined in ‘Data.Monoid’
instance forall (k :: BOX) (f :: k -> *) (a :: k).
Show (f a) =>
Show (Alt f a)
-- Defined in ‘Data.Monoid’
...plus 33 others
(use -fprint-potential-instances to see them all)
In a stmt of an interactive GHCi command: print it
<interactive>:10:1:
<interactive>:10:1: error:
No instance for (Show a1) arising from a use of ‘print’
Cannot resolve unknown runtime type ‘a1’
Use :print or :force to determine these types
Relevant bindings include it :: a1 (bound at <interactive>:10:1)
Note: there are several potential instances:
Potential instances:
instance Show TyCon -- Defined in ‘Data.Typeable.Internal’
instance Show TypeRep -- Defined in ‘Data.Typeable.Internal’
instance Show a => Show (Maybe a) -- Defined in ‘GHC.Show’
...plus 30 others
(use -fprint-potential-instances to see them all)
In a stmt of an interactive GHCi command: print it
..\..\typecheck\should_run\Defer01.hs:11:40: warning:
Couldn't match type ‘Char’ with ‘[Char]’
Expected type: String
Actual type: Char
In the first argument of ‘putStr’, namely ‘','’
In the second argument of ‘(>>)’, namely ‘putStr ','’
In the expression: putStr "Hello World" >> putStr ','
..\..\typecheck\should_run\Defer01.hs:14:5: warning:
Couldn't match expected type ‘Int’ with actual type ‘Char’
In the expression: 'p'
In an equation for ‘a’: a = 'p'
..\..\typecheck\should_run\Defer01.hs:18:9: warning:
No instance for (Eq B) arising from a use of ‘==’
In the expression: x == x
In an equation for ‘b’: b x = x == x
..\..\typecheck\should_run\Defer01.hs:25:4: warning:
Couldn't match type ‘Int’ with ‘Bool’
Inaccessible code in
a pattern with constructor: C2 :: Bool -> C Bool,
in an equation for ‘c’
In the pattern: C2 x
In an equation for ‘c’: c (C2 x) = True
..\..\typecheck\should_run\Defer01.hs:28:5: warning:
No instance for (Num (a -> a)) arising from the literal ‘1’
(maybe you haven't applied a function to enough arguments?)
In the expression: 1
In an equation for ‘d’: d = 1
..\..\typecheck\should_run\Defer01.hs:31:5: warning:
Couldn't match expected type ‘Char -> t’ with actual type ‘Char’
Relevant bindings include
f :: t (bound at ..\..\typecheck\should_run\Defer01.hs:31:1)
The function ‘e’ is applied to one argument,
but its type ‘Char’ has none
In the expression: e 'q'
In an equation for ‘f’: f = e 'q'
..\..\typecheck\should_run\Defer01.hs:34:8: warning:
Couldn't match expected type ‘Char’ with actual type ‘a’
‘a’ is a rigid type variable bound by
the type signature for:
h :: a -> (Char, Char)
at ..\..\typecheck\should_run\Defer01.hs:33:6
Relevant bindings include
x :: a (bound at ..\..\typecheck\should_run\Defer01.hs:34:3)
h :: a -> (Char, Char)
(bound at ..\..\typecheck\should_run\Defer01.hs:34:1)
In the expression: x
In the expression: (x, 'c')
..\..\typecheck\should_run\Defer01.hs:39:17: warning:
Couldn't match expected type ‘Bool’ with actual type ‘T a’
Relevant bindings include
a :: a (bound at ..\..\typecheck\should_run\Defer01.hs:39:3)
i :: a -> () (bound at ..\..\typecheck\should_run\Defer01.hs:39:1)
In the first argument of ‘not’, namely ‘(K a)’
In the expression: (not (K a))
..\..\typecheck\should_run\Defer01.hs:43:5: warning:
No instance for (MyClass a1) arising from a use of ‘myOp’
In the expression: myOp 23
In an equation for ‘j’: j = myOp 23
..\..\typecheck\should_run\Defer01.hs:43:10: warning:
No instance for (Num a1) arising from the literal ‘23’
The type variable ‘a1’ is ambiguous
Note: there are several potential instances:
instance Num Integer -- Defined in ‘GHC.Num’
instance Num Double -- Defined in ‘GHC.Float’
instance Num Float -- Defined in ‘GHC.Float’
...plus two others
In the first argument of ‘myOp’, namely ‘23’
In the expression: myOp 23
In an equation for ‘j’: j = myOp 23
..\..\typecheck\should_run\Defer01.hs:45:6: warning:
Couldn't match type ‘Int’ with ‘Bool’
Inaccessible code in
the type signature for:
k :: (Int ~ Bool) => Int -> Bool
In the ambiguity check for the type signature for ‘k’:
k :: (Int ~ Bool) => Int -> Bool
To defer the ambiguity check to use sites, enable AllowAmbiguousTypes
In the type signature for ‘k’: k :: (Int ~ Bool) => Int -> Bool
..\..\typecheck\should_run\Defer01.hs:45:6: warning:
Couldn't match expected type ‘Bool’ with actual type ‘Int’
In the ambiguity check for the type signature for ‘k’:
k :: (Int ~ Bool) => Int -> Bool
To defer the ambiguity check to use sites, enable AllowAmbiguousTypes
In the type signature for ‘k’: k :: (Int ~ Bool) => Int -> Bool
..\..\typecheck\should_run\Defer01.hs:45:6: warning:
Couldn't match type ‘Int’ with ‘Bool’
Inaccessible code in
the type signature for:
k :: (Int ~ Bool) => Int -> Bool
..\..\typecheck\should_run\Defer01.hs:46:7: warning:
Couldn't match expected type ‘Bool’ with actual type ‘Int’
In the expression: x
In an equation for ‘k’: k x = x
..\..\typecheck\should_run\Defer01.hs:49:5: warning:
Couldn't match expected type ‘IO a0’
with actual type ‘Char -> IO ()’
Probable cause: ‘putChar’ is applied to too few arguments
In the first argument of ‘(>>)’, namely ‘putChar’
In the expression: putChar >> putChar 'p'
*** Exception: ..\..\typecheck\should_run\Defer01.hs:11:40: error:
Couldn't match type ‘Char’ with ‘[Char]’
Expected type: String
Actual type: Char
In the first argument of ‘putStr’, namely ‘','’
In the second argument of ‘(>>)’, namely ‘putStr ','’
In the expression: putStr "Hello World" >> putStr ','
(deferred type error)
*** Exception: ..\..\typecheck\should_run\Defer01.hs:14:5: error:
Couldn't match expected type ‘Int’ with actual type ‘Char’
In the expression: 'p'
In an equation for ‘a’: a = 'p'
(deferred type error)
*** Exception: ..\..\typecheck\should_run\Defer01.hs:18:9: error:
No instance for (Eq B) arising from a use of ‘==’
In the expression: x == x
In an equation for ‘b’: b x = x == x
(deferred type error)
<interactive>:7:11: error:
Couldn't match type ‘Bool’ with ‘Int’
Expected type: C Int
Actual type: C Bool
In the first argument of ‘c’, namely ‘(C2 True)’
In the first argument of ‘print’, namely ‘(c (C2 True))’
*** Exception: ..\..\typecheck\should_run\Defer01.hs:28:5: error:
No instance for (Num (a -> a)) arising from the literal ‘1’
(maybe you haven't applied a function to enough arguments?)
In the expression: 1
In an equation for ‘d’: d = 1
(deferred type error)
*** Exception: ..\..\typecheck\should_run\Defer01.hs:31:5: error:
Couldn't match expected type ‘Char -> t’ with actual type ‘Char’
Relevant bindings include
f :: t (bound at ..\..\typecheck\should_run\Defer01.hs:31:1)
The function ‘e’ is applied to one argument,
but its type ‘Char’ has none
In the expression: e 'q'
In an equation for ‘f’: f = e 'q'
(deferred type error)
*** Exception: ..\..\typecheck\should_run\Defer01.hs:34:8: error:
Couldn't match expected type ‘Char’ with actual type ‘a’
‘a’ is a rigid type variable bound by
the type signature for:
h :: a -> (Char, Char)
at ..\..\typecheck\should_run\Defer01.hs:33:6
Relevant bindings include
x :: a (bound at ..\..\typecheck\should_run\Defer01.hs:34:3)
h :: a -> (Char, Char)
(bound at ..\..\typecheck\should_run\Defer01.hs:34:1)
In the expression: x
In the expression: (x, 'c')
(deferred type error)
*** Exception: ..\..\typecheck\should_run\Defer01.hs:39:17: error:
Couldn't match expected type ‘Bool’ with actual type ‘T a’
Relevant bindings include
a :: a (bound at ..\..\typecheck\should_run\Defer01.hs:39:3)
i :: a -> () (bound at ..\..\typecheck\should_run\Defer01.hs:39:1)
In the first argument of ‘not’, namely ‘(K a)’
In the expression: (not (K a))
(deferred type error)
*** Exception: ..\..\typecheck\should_run\Defer01.hs:43:5: error:
No instance for (MyClass a1) arising from a use of ‘myOp’
In the expression: myOp 23
In an equation for ‘j’: j = myOp 23
(deferred type error)
<interactive>:13:8: error:
Couldn't match expected type ‘Bool’ with actual type ‘Int’
In the first argument of ‘print’, namely ‘(k 2)’
In the expression: print (k 2)
In an equation for ‘it’: it = print (k 2)
*** Exception: ..\..\typecheck\should_run\Defer01.hs:49:5: error:
Couldn't match expected type ‘IO a0’
with actual type ‘Char -> IO ()’
Probable cause: ‘putChar’ is applied to too few arguments
In the first argument of ‘(>>)’, namely ‘putChar’
In the expression: putChar >> putChar 'p'
(deferred type error)
../../typecheck/should_run/Defer01.hs:11:40: warning:
Couldn't match type ‘Char’ with ‘[Char]’
Expected type: String
Actual type: Char
In the first argument of ‘putStr’, namely ‘','’
In the second argument of ‘(>>)’, namely ‘putStr ','’
In the expression: putStr "Hello World" >> putStr ','
../../typecheck/should_run/Defer01.hs:14:5: warning:
Couldn't match expected type ‘Int’ with actual type ‘Char’
In the expression: 'p'
In an equation for ‘a’: a = 'p'
../../typecheck/should_run/Defer01.hs:18:9: warning:
No instance for (Eq B) arising from a use of ‘==’
In the expression: x == x
In an equation for ‘b’: b x = x == x
../../typecheck/should_run/Defer01.hs:25:4: warning:
Couldn't match type ‘Int’ with ‘Bool’
Inaccessible code in
a pattern with constructor: C2 :: Bool -> C Bool,
in an equation for ‘c’
In the pattern: C2 x
In an equation for ‘c’: c (C2 x) = True
../../typecheck/should_run/Defer01.hs:28:5: warning:
No instance for (Num (a -> a)) arising from the literal ‘1’
(maybe you haven't applied a function to enough arguments?)
In the expression: 1
In an equation for ‘d’: d = 1
../../typecheck/should_run/Defer01.hs:31:5: warning:
Couldn't match expected type ‘Char -> t’ with actual type ‘Char’
Relevant bindings include
f :: t (bound at ../../typecheck/should_run/Defer01.hs:31:1)
The function ‘e’ is applied to one argument,
but its type ‘Char’ has none
In the expression: e 'q'
In an equation for ‘f’: f = e 'q'
../../typecheck/should_run/Defer01.hs:34:8: warning:
Couldn't match expected type ‘Char’ with actual type ‘a’
‘a’ is a rigid type variable bound by
the type signature for:
h :: a -> (Char, Char)
at ../../typecheck/should_run/Defer01.hs:33:6
Relevant bindings include
x :: a (bound at ../../typecheck/should_run/Defer01.hs:34:3)
h :: a -> (Char, Char)
(bound at ../../typecheck/should_run/Defer01.hs:34:1)
In the expression: x
In the expression: (x, 'c')
../../typecheck/should_run/Defer01.hs:39:17: warning:
Couldn't match expected type ‘Bool’ with actual type ‘T a’
Relevant bindings include
a :: a (bound at ../../typecheck/should_run/Defer01.hs:39:3)
i :: a -> () (bound at ../../typecheck/should_run/Defer01.hs:39:1)
In the first argument of ‘not’, namely ‘(K a)’
In the expression: (not (K a))
../../typecheck/should_run/Defer01.hs:43:5: warning:
No instance for (MyClass a1) arising from a use of ‘myOp’
In the expression: myOp 23
In an equation for ‘j’: j = myOp 23
../../typecheck/should_run/Defer01.hs:43:10: warning:
No instance for (Num a1) arising from the literal ‘23’
The type variable ‘a1’ is ambiguous
Potential instances:
instance Num Integer -- Defined in ‘GHC.Num’
instance Num Double -- Defined in ‘GHC.Float’
instance Num Float -- Defined in ‘GHC.Float’
...plus two others
(use -fprint-potential-instances to see them all)
In the first argument of ‘myOp’, namely ‘23’
In the expression: myOp 23
In an equation for ‘j’: j = myOp 23
../../typecheck/should_run/Defer01.hs:45:6: warning:
Couldn't match type ‘Int’ with ‘Bool’
Inaccessible code in
the type signature for:
k :: (Int ~ Bool) => Int -> Bool
In the ambiguity check for the type signature for ‘k’:
k :: (Int ~ Bool) => Int -> Bool
To defer the ambiguity check to use sites, enable AllowAmbiguousTypes
In the type signature for ‘k’: k :: (Int ~ Bool) => Int -> Bool
../../typecheck/should_run/Defer01.hs:45:6: warning:
Couldn't match expected type ‘Bool’ with actual type ‘Int’
In the ambiguity check for the type signature for ‘k’:
k :: (Int ~ Bool) => Int -> Bool
To defer the ambiguity check to use sites, enable AllowAmbiguousTypes
In the type signature for ‘k’: k :: (Int ~ Bool) => Int -> Bool
../../typecheck/should_run/Defer01.hs:45:6: warning:
Couldn't match type ‘Int’ with ‘Bool’
Inaccessible code in
the type signature for:
k :: (Int ~ Bool) => Int -> Bool
../../typecheck/should_run/Defer01.hs:46:7: warning:
Couldn't match expected type ‘Bool’ with actual type ‘Int’
In the expression: x
In an equation for ‘k’: k x = x
../../typecheck/should_run/Defer01.hs:49:5: warning:
Couldn't match expected type ‘IO a0’
with actual type ‘Char -> IO ()’
Probable cause: ‘putChar’ is applied to too few arguments
In the first argument of ‘(>>)’, namely ‘putChar’
In the expression: putChar >> putChar 'p'
*** Exception: ../../typecheck/should_run/Defer01.hs:11:40: error:
Couldn't match type ‘Char’ with ‘[Char]’
Expected type: String
Actual type: Char
In the first argument of ‘putStr’, namely ‘','’
In the second argument of ‘(>>)’, namely ‘putStr ','’
In the expression: putStr "Hello World" >> putStr ','