
#10875: Unexpected defaulting of partial type signatures and inconsistent behaviour when -fdefer-typed-holes is set. -------------------------------------+------------------------------------- Reporter: holzensp | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.2 Resolution: | Keywords: | PartialTypeSignatures TypedHoles Operating System: MacOS X | Architecture: x86_64 Type of failure: Incorrect | (amd64) warning at compile-time | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by holzensp): I just realised that the above loss of the `RealFrac` constraint, may well be because GHC has nowhere to put it. I tried `(undefined::_ => _inner)`, but it seems the constraints hole is only used at top-level (i.e. GHC didn't output any message for this `_`). A further attempt using `ImplicitParams` also gave unexpected results. Consider this program: {{{#!hs {-#LANGUAGE NoMonomorphismRestriction #-} {-#LANGUAGE PartialTypeSignatures #-} {-#LANGUAGE NamedWildCards #-} {-#LANGUAGE ImplicitParams #-} foo :: _ => _outer foo x = round (?hole (1 + x)) }}} which yields {{{ Foo.hs:6:8: Warning: Found hole ‘_’ with inferred constraints: (Integral b, Num a, RealFrac a, ?hole::a -> a) In the type signature for ‘foo’: _ => _outer Foo.hs:6:13: Warning: Found hole ‘_outer’ with type: a1 -> b Where: ‘b’ is a rigid type variable bound by the inferred type of foo :: (Integral b, Num a1, RealFrac a, ?hole::a1 -> a) => a1 -> b at Foo.hs:7:1 ‘a1’ is a rigid type variable bound by the inferred type of foo :: (Integral b, Num a1, RealFrac a, ?hole::a1 -> a) => a1 -> b at Foo.hs:7:1 In the type signature for ‘foo’: _ => _outer Ok, modules loaded: Main. }}} Notice how the first message, regarding `_` is too restrictive, by demanding that `?hole::a -> a`. However, the second message is more general, stating `?hole::a1 -> a`. Could this just be a pretty printer issue, where the first message discards the subscript of the type variable? Another surprise occurs when I remove the parenthesis and use `$` instead: {{{#!hs foo x = round $ ?hole (1 + x) }}} results in {{{ Foo.hs:6:8: Warning: Found hole ‘_’ with inferred constraints: (Integral b, Num a, RealFrac r, ?hole::a -> r) In the type signature for ‘foo’: _ => _outer Foo.hs:6:13: Warning: Found hole ‘_outer’ with type: a -> b Where: ‘b’ is a rigid type variable bound by the inferred type of foo :: (Integral b, Num a, RealFrac r, ?hole::a -> r) => a -> b at Foo.hs:7:1 ‘a’ is a rigid type variable bound by the inferred type of foo :: (Integral b, Num a, RealFrac r, ?hole::a -> r) => a -> b at Foo.hs:7:1 In the type signature for ‘foo’: _ => _outer Ok, modules loaded: Main. }}} This is the result I was looking for! -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10875#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler