[GHC] #13060: Visible type application doesn't work for functions with inferred types
GHC
ghc-devs at haskell.org
Tue Jan 3 20:35:08 UTC 2017
#13060: Visible type application doesn't work for functions with inferred types
-------------------------------------+-------------------------------------
Reporter: Feuerbach | Owner:
Type: bug | Status: closed
Priority: normal | Milestone:
Component: Compiler (Type | Version: 8.0.1
checker) |
Resolution: invalid | Keywords:
Operating System: Unknown/Multiple | Architecture:
Type of failure: GHC rejects | Unknown/Multiple
valid program | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Changes (by Feuerbach):
* status: new => closed
* resolution: => invalid
Comment:
Thanks Richard, this makes sense.
I agree that depending on the inferred order of type variables in actual
code would be a bad idea.
In my case, I was just trying to evaluate something quickly in ghci like
this:
{{{
*Main> description decoGrid
<interactive>:64:1: error:
• Ambiguous type variable ‘a0’ arising from a use of ‘description’
prevents the constraint ‘(LayoutModifier
(Decoration DefaultDecoration
DefaultShrinker)
a0)’ from being solved.
Probable fix: use a type annotation to specify what ‘a0’ should be.
These potential instance exist:
one instance involving out-of-scope types
(use -fprint-potential-instances to see them all)
• In the expression: description decoGrid
In an equation for ‘it’: it = description decoGrid
<interactive>:64:13: error:
• Ambiguous type variable ‘a0’ arising from a use of ‘decoGrid’
prevents the constraint ‘(Eq a0)’ from being solved.
Probable fix: use a type annotation to specify what ‘a0’ should be.
These potential instances exist:
instance Eq XEvent -- Defined in ‘Graphics.X11.Xlib.Event’
instance Eq FontSet -- Defined in ‘Graphics.X11.Xlib.Extras’
instance Eq FontStruct -- Defined in ‘Graphics.X11.Xlib.Font’
...plus 61 others
...plus 138 instances involving out-of-scope types
(use -fprint-potential-instances to see them all)
• In the first argument of ‘description’, namely ‘decoGrid’
In the expression: description decoGrid
In an equation for ‘it’: it = description decoGrid
*Main> :t decoGrid
decoGrid
:: forall {a}.
Eq a =>
ModifiedLayout
(Decoration DefaultDecoration DefaultShrinker) Grid a
*Main> -- ok, so I need to apply decoGrid to the right type param
*Main> description (decoGrid @Window)
<interactive>:67:14: error:
• Cannot apply expression of type ‘ModifiedLayout
(Decoration DefaultDecoration
DefaultShrinker) Grid a0’
to a visible type argument ‘Window’
• In the first argument of ‘description’, namely
‘(decoGrid @Window)’
In the expression: description (decoGrid @Window)
In an equation for ‘it’: it = description (decoGrid @Window)
*Main> -- this works:
*Main> :set -XPartialTypeSignatures -Wno-partial-type-signatures
*Main> description (decoGrid :: _ Window)
"DefaultDecoration Grid"
}}}
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13060#comment:2>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list