[GHC] #9901: Error message: f is applied to two arguments, but its type has only two (sic)

#9901: Error message: f is applied to two arguments, but its type has only two (sic) -------------------------------------+------------------------------------- Reporter: zardoz | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler (Type | Version: 7.8.3 checker) | Operating System: Keywords: | Unknown/Multiple Architecture: Unknown/Multiple | Type of failure: Difficulty: Unknown | None/Unknown Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- I occasionally get type errors where the error message refers to a function’s arity in a contradictory way:
The function ‘X’ is applied to two arguments, […] but its type has only two.
Here’s a full error message of this kind: lenstest.hs:89:12: Couldn't match type ‘Either String Int’ with ‘Maybe b0’ Expected type: [Char] -> Either String Int Actual type: [Char] -> Maybe b0 The function ‘preview’ is applied to two arguments, but its type ‘Getting (Data.Monoid.First b0) (Either b0 c0) b0 -> [Char] -> Maybe b0’ has only two In the second argument of ‘($)’, namely ‘(preview _Left "abc" :: Either String Int)’ In a stmt of a 'do' block: print $ (preview _Left "abc" :: Either String Int) Failed, modules loaded: none. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9901 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9901: Error message: f is applied to two arguments, but its type has only two (sic) -------------------------------------+------------------------------------- Reporter: zardoz | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.3 (Type checker) | Keywords: Resolution: | Architecture: Unknown/Multiple Operating System: | Difficulty: Unknown Unknown/Multiple | Blocked By: Type of failure: | Related Tickets: None/Unknown | Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by simonpj): Would you care to give a test case? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9901#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9901: Error message: f is applied to two arguments, but its type has only two (sic) -------------------------------------+------------------------------------- Reporter: zardoz | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.3 (Type checker) | Keywords: Resolution: | Architecture: Unknown/Multiple Operating System: | Difficulty: Unknown Unknown/Multiple | Blocked By: Type of failure: | Related Tickets: None/Unknown | Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by Yuras): It is hard to tell exactly without test case, but I'm almost sure it is a duplicate of #9605 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9901#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9901: Error message: f is applied to two arguments, but its type has only two (sic) -------------------------------------+------------------------------------- Reporter: zardoz | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler (Type | Version: 7.8.3 checker) | Keywords: Resolution: | Architecture: Operating System: Unknown/Multiple | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by zardoz): Sorry, I lost track of this. I’ve attached a program which will reproduce this message on GHC 7.8.4. It doesn’t seem to relate to a forgotten do. It’s triggered by the wrong type annotation to the value of «preview». -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9901#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9901: Error message: f is applied to two arguments, but its type has only two (sic) -------------------------------------+------------------------------------- Reporter: zardoz | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler (Type | Version: 7.8.3 checker) | Keywords: Resolution: | Architecture: Operating System: Unknown/Multiple | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by simonpj): Can you offer an example that does not depend on `lens` with its zillions of dependencies? Usually you can just write down the types of the imports, thus: {{{ preview :: <type of preview> preview = error "urk" }}} Also is the `UnicodeSyntax` significant. Thakns -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9901#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9901: Error message: f is applied to two arguments, but its type has only two (sic) -------------------------------------+------------------------------------- Reporter: zardoz | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler (Type | Version: 7.8.3 checker) | Keywords: Resolution: | Architecture: Operating System: Unknown/Multiple | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by zardoz): I’ve updated the attachment. Hopefully this should go through with just «base» installed. I’m out of my depth on the language pragmas. I added them as requested by GHC when mocking the respective types. The error message seems to be the same as before. This program yields me: {{{ test.hs:22:17: Couldn't match type ‘Either String Int’ with ‘Maybe a0’ Expected type: Either a1 [Char] -> Either String Int Actual type: Either a1 [Char] -> Maybe a0 The function ‘preview’ is applied to two arguments, but its type ‘Getting (Data.Monoid.First a0) s0 a0 -> Either a1 [Char] -> Maybe a0’ has only two In the second argument of ‘($)’, namely ‘(preview _Left (Right "abc") :: Either String Int)’ In the expression: print $ (preview _Left (Right "abc") :: Either String Int) Failed, modules loaded: none. }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9901#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9901: Error message: f is applied to two arguments, but its type has only two (sic) -------------------------------------+------------------------------------- Reporter: zardoz | Owner: Type: bug | Status: infoneeded Priority: normal | Milestone: Component: Compiler (Type | Version: 7.8.3 checker) | Keywords: Resolution: | Architecture: Operating System: Unknown/Multiple | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #9605 | Differential Revisions: -------------------------------------+------------------------------------- Changes (by Yuras): * status: new => infoneeded * related: => #9605 Comment: Thank you for the test case. That is what I get with HEAD: {{{#!haskell test.hs:22:17: Couldn't match type ‘Maybe a0’ with ‘Either String Int’ Expected type: Either a1 [Char] -> Either String Int Actual type: Either a1 [Char] -> Maybe a0 The function ‘preview’ is applied to two arguments, its type is ‘Getting (Data.Monoid.First a0) s0 a0 -> m0 (Maybe a0)’, it is specialized to ‘Getting (Data.Monoid.First a0) s0 a0 -> Either a1 [Char] -> Maybe a0’ In the second argument of ‘($)’, namely ‘(preview _Left (Right "abc") :: Either String Int)’ In the expression: print $ (preview _Left (Right "abc") :: Either String Int) }}} That looks right for me, so I'd say the issue is a duplicate. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9901#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9901: Error message: f is applied to two arguments, but its type has only two (sic) -------------------------------------+------------------------------------- Reporter: zardoz | Owner: Type: bug | Status: closed Priority: normal | Milestone: Component: Compiler (Type | Version: 7.8.3 checker) | Keywords: Resolution: duplicate | Architecture: Operating System: Unknown/Multiple | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #9605 | Differential Revisions: -------------------------------------+------------------------------------- Changes (by thomie): * status: infoneeded => closed * resolution: => duplicate Comment: The fix for #9605 will be in 7.10. @zardoz: please reopen if you don't think your issue is fixed in 7.10. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9901#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC