[GHC] #14963: ghci -fdefer-type-errors can't run IO action from another module

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
40 messages Options
12
Reply | Threaded
Open this post in threaded view
|

[GHC] #14963: ghci -fdefer-type-errors can't run IO action from another module

GHC - devs mailing list
#14963: ghci -fdefer-type-errors can't run IO action from another module
-------------------------------------+-------------------------------------
           Reporter:  elaforge       |             Owner:  (none)
               Type:  bug            |            Status:  new
           Priority:  normal         |         Milestone:
          Component:  GHCi           |           Version:  8.4.1
           Keywords:                 |  Operating System:  Unknown/Multiple
       Architecture:                 |   Type of failure:  None/Unknown
  Unknown/Multiple                   |
          Test Case:                 |        Blocked By:
           Blocking:                 |   Related Tickets:
Differential Rev(s):                 |         Wiki Page:
-------------------------------------+-------------------------------------
 This is enough to trigger a crash on OS X and Linux:

 Bug1.hs:
 {{{
 module Bug1.hs where
 import qualified Bug2

 test :: IO Bool
 test = Bug2.failure
 }}}

 Bug2.hs:
 {{{
 module Bug2 where

 failure :: IO Bool
 failure = return False
 }}}

 Shell:
 {{{
 % ghci -fdefer-type-errors -ignore-dot-ghci
 GHCi, version 8.4.1: http://www.haskell.org/ghc/  :? for help
 Prelude> :load Bug
 [1 of 2] Compiling Bug2             ( Bug2.hs, interpreted )
 [2 of 2] Compiling Bug              ( Bug.hs, interpreted )
 Ok, two modules loaded.
 *Bug> test
 ghc: panic! (the 'impossible' happened)
   (GHC version 8.4.1 for x86_64-apple-darwin):
         nameModule
   system $dShow_a1LX
   Call stack:
       CallStack (from HasCallStack):
         callStackDoc, called at compiler/utils/Outputable.hs:1150:37 in
 ghc:Outputable
         pprPanic, called at compiler/basicTypes/Name.hs:241:3 in ghc:Name

 Please report this as a GHC bug:  http://www.haskell.org/ghc/reportabug
 }}}

 This is specific to 8.4.1, in 8.0.2 I get "False" as expected.  If I leave
 off -fdefer-type-errors, it works.  It also seems to be ghci only,
 compiling with -fdefer-type-errors doesn't have the problem.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14963>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler

_______________________________________________
ghc-tickets mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-tickets
Reply | Threaded
Open this post in threaded view
|

Re: [GHC] #14963: ghci -fdefer-type-errors can't run IO action from another module

GHC - devs mailing list
#14963: ghci -fdefer-type-errors can't run IO action from another module
-------------------------------------+-------------------------------------
        Reporter:  elaforge          |                Owner:  (none)
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  GHCi              |              Version:  8.4.1
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------
Changes (by chak):

 * cc: chak@… (added)


--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14963#comment:1>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler

_______________________________________________
ghc-tickets mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-tickets
Reply | Threaded
Open this post in threaded view
|

Re: [GHC] #14963: ghci -fdefer-type-errors can't run IO action from another module

GHC - devs mailing list
In reply to this post by GHC - devs mailing list
#14963: ghci -fdefer-type-errors can't run IO action from another module
-------------------------------------+-------------------------------------
        Reporter:  elaforge          |                Owner:  (none)
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  GHCi              |              Version:  8.4.1
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by monoidal):

 The same happens with just one module:

 {{{
 test :: IO Bool
 test = return True
 }}}

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14963#comment:2>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler

_______________________________________________
ghc-tickets mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-tickets
Reply | Threaded
Open this post in threaded view
|

Re: [GHC] #14963: ghci -fdefer-type-errors can't run IO action from another module

GHC - devs mailing list
In reply to this post by GHC - devs mailing list
#14963: ghci -fdefer-type-errors can't run IO action from another module
-------------------------------------+-------------------------------------
        Reporter:  elaforge          |                Owner:  (none)
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  GHCi              |              Version:  8.4.1
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by RyanGlScott):

 I must be doing something wrong here. I created a file named `Bug.hs` with
 the contents of comment:2, and tried loading it like so:

 {{{
 $ ~/Software/ghc-8.4.1/bin/ghci -fdefer-type-errors -ignore-dot-ghciGHCi,
 version 8.4.1: http://www.haskell.org/ghc/  :? for help
 Prelude> :load Bug
 [1 of 1] Compiling Main             ( Bug.hs, interpreted )
 Ok, one module loaded.
 }}}

 Which appears to work without issue. What am I missing?

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14963#comment:3>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler

_______________________________________________
ghc-tickets mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-tickets
Reply | Threaded
Open this post in threaded view
|

Re: [GHC] #14963: ghci -fdefer-type-errors can't run IO action from another module

GHC - devs mailing list
In reply to this post by GHC - devs mailing list
#14963: ghci -fdefer-type-errors can't run IO action from another module
-------------------------------------+-------------------------------------
        Reporter:  elaforge          |                Owner:  (none)
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  GHCi              |              Version:  8.4.1
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by simonpj):

 I can repro the original 2-module report, with the GHC 8.4.2 branch, and
 with HEAD.  Definite bug here!

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14963#comment:4>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler

_______________________________________________
ghc-tickets mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-tickets
Reply | Threaded
Open this post in threaded view
|

Re: [GHC] #14963: ghci -fdefer-type-errors can't run IO action from another module

GHC - devs mailing list
In reply to this post by GHC - devs mailing list
#14963: ghci -fdefer-type-errors can't run IO action from another module
-------------------------------------+-------------------------------------
        Reporter:  elaforge          |                Owner:  (none)
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  GHCi              |              Version:  8.4.1
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by monoidal):

 After `:load Bug` you need to examine the value `test` in ghci.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14963#comment:5>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler

_______________________________________________
ghc-tickets mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-tickets
Reply | Threaded
Open this post in threaded view
|

Re: [GHC] #14963: ghci -fdefer-type-errors can't run IO action from another module

GHC - devs mailing list
In reply to this post by GHC - devs mailing list
#14963: ghci -fdefer-type-errors can't run IO action from another module
-------------------------------------+-------------------------------------
        Reporter:  elaforge          |                Owner:  (none)
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  GHCi              |              Version:  8.4.1
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by RyanGlScott):

 Oops, I overlooked that important detail!

 Commit a211dca8236fb8c7ec632278f761121beeac1438 (`Fix defer-out-of-scope-
 variables`) is what caused this.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14963#comment:6>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler

_______________________________________________
ghc-tickets mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-tickets
Reply | Threaded
Open this post in threaded view
|

Re: [GHC] #14963: ghci -fdefer-type-errors can't run IO action from another module

GHC - devs mailing list
In reply to this post by GHC - devs mailing list
#14963: ghci -fdefer-type-errors can't run IO action from another module
-------------------------------------+-------------------------------------
        Reporter:  elaforge          |                Owner:  (none)
            Type:  bug               |               Status:  new
        Priority:  high              |            Milestone:  8.4.2
       Component:  GHCi              |              Version:  8.4.1
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------
Changes (by RyanGlScott):

 * priority:  normal => high
 * milestone:   => 8.4.2


Comment:

 Since this is a regression from 8.2, I'm opting to change the milestone
 and priority. Do change if you feel this isn't warranted.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14963#comment:7>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler

_______________________________________________
ghc-tickets mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-tickets
Reply | Threaded
Open this post in threaded view
|

Re: [GHC] #14963: ghci -fdefer-type-errors can't run IO action from another module

GHC - devs mailing list
In reply to this post by GHC - devs mailing list
#14963: ghci -fdefer-type-errors can't run IO action from another module
-------------------------------------+-------------------------------------
        Reporter:  elaforge          |                Owner:  (none)
            Type:  bug               |               Status:  new
        Priority:  high              |            Milestone:  8.4.2
       Component:  GHCi              |              Version:  8.4.1
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by simonpj):

 It took me quite a while to find out what was going on here.

 I started with a file containing only
 {{{
 test :: IO Bool
 test = return True
 }}}
 Then load into GHCi, with `-fdefer-type-errors`
 {{{
 ghc --interactive -fdefer-type-errors Foo.hs
 }}}
 Now just evaluate `test`. Here's what I see from `-ddump-tc -ddump-ds`
 with a little extra debug tracing, when evaluating `test` at the GHCi
 prompt:
 {{{
 Typechecked expr do it_a1PP <- {>>=: GHC.Base.bindIO @ Bool
                                      @ [()]{let {EvBinds{[W] $dShow_a1Qg =
 GHC.Show.$fShowBool}} <>, <>}
                                            {<> |> <IO [()]>_R}
                                 fail: "noSyntaxExpr"{}{<>}} /\(@ a_a1Q5).
                                                             let
 {EvBinds{[W] $dGHCiSandboxIO_a1Q7
 = GHC.GHCi.$fGHCiSandboxIOIO}}
 GHC.GHCi.ghciStepIO @ IO
 $dGHCiSandboxIO_a1Q7
                                                             @ a_a1Q5 ::

   ic_tythings:
   ic_insts:
   ic_rn_gbl_env (LocalDef) [Foo.test defined at Foo.hs:11:1]
 newTcEvBinds unique = a1Ql
 checkSatisfiability { {}
 checkSatisfiability } {}
 unflattenGivens []
 ds BindStmt
     /\(@ a_a1Q5).
     let {EvBinds{[W] $dGHCiSandboxIO_a1Q7 = $fGHCiSandboxIOIO}}
     ghciStepIO @ IO $dGHCiSandboxIO_a1Q7 @ a_a1Q5 ::
       forall a_a1PO. IO a_a1PO -> IO a_a1PO
   @ Bool
     test
     |> <IO Bool>_R
   ---
   (\ (@ a_a1Q5) ->
      let {
        $dGHCiSandboxIO_a1Q7 :: GHCiSandboxIO IO
        [LclId]
        $dGHCiSandboxIO_a1Q7 = $fGHCiSandboxIOIO } in
      ghciStepIO @ IO $dGHCiSandboxIO_a1Q7 @ a_a1Q5)
     @ Bool test
 *** Core Lint errors : in result of desugar expression ***
 <no location info>: warning:
     In the expression: print @ Bool $dShow_a1Qg it_a1PP
     $dShow_a1Qg :: Show Bool
     [LclId] is out of scope
 *** Offending Program ***
 bindIO
   @ Bool
   @ [()]
   (let {
      $dShow_a1Qg :: Show Bool      <----- Right binding, wrongly scoped!
      [LclId]
      $dShow_a1Qg = $fShowBool } in
    (\ (@ a_a1Q5) ->
       let {
         $dGHCiSandboxIO_a1Q7 :: GHCiSandboxIO IO
         [LclId]
         $dGHCiSandboxIO_a1Q7 = $fGHCiSandboxIOIO } in
       ghciStepIO @ IO $dGHCiSandboxIO_a1Q7 @ a_a1Q5)
      @ Bool test)
   (\ (it_a1PP :: Bool) ->
      thenIO
        @ ()
        @ [()]
        (print @ Bool $dShow_a1Qg it_a1PP)
        (returnIO
           @ [()]
           (: @ ()
              (unsafeCoerce# @ 'LiftedRep @ 'LiftedRep @ Bool @ () it_a1PP)
              ([] @ ()))))
 *** End of Offense ***
 }}}

 Here's the deal.

 * When you type `ghci> test` to the GHCi prompt, GHC typechecks (roughly)
 {{{
 do { it <- sandbox test
    ; print it
    ; return () }
 }}}
   This is Plan A in TcRnDriver.tcUserStmt.

 * When typechecking the initial `BindStmt` of the `do` block, we end up
 invoking `tcSyntaxOp` in `TcMatches.TcDoStmt`

 * Bizarrely, we then typecheck the rest of the `do` block inside the
 `thing_inside` argument to `tcSyntaxOp`.

 * `TcExpr.tcSyntaxOp` ends up calling `tcSyntaxArgE`, which calls
 `tcSkolemize`, which builds an implication constraint.

 * This implication constraint gets wrapped around the first argument of
 the bind, namely `sandbox test`.  But since the `thing_inside` includes
 the `Show` constraint arising from `print it`, the `Show` dictionary lands
 up in the evidence bindings for the implication, and hence gets wrapped
 around the `sandbox test` RHS only. Utterly bogus.

 * All this happens always, I think.  Usually `TcUnify.implicationNeeded`
 ends up being false, so we don't actually create an implication, and so
 the evidence bindings don't end up in the wrong place.  But in the special
 case of GHCi with `-fdefer-type-errors` we (unusually) you'll see that
 `implicationNeeded` returns True.  And that's why the bug manifest only in
 GHCi, and even then only with `-fdefer-type-errors`.

 Blimey.

 --------------------------------
 All of this is a result of the impenetrable code in `tcSyntaxOp`, which
 Richard introduced in
 {{{
 commit 00cbbab3362578df44851442408a8b91a2a769fa
 Author: Richard Eisenberg <[hidden email]>
 Date:   Wed Jan 13 23:29:17 2016 -0500

 ...

     In addition, this patch does a significant reworking of
     RebindableSyntax, allowing much more freedom in the types
     of the rebindable operators. For example, we can now have
     `negate :: Int -> Bool` and
     `(>>=) :: m a -> (forall x. a x -> m b) -> m b`. The magic
     is in tcSyntaxOp.
 }}}
 To me it seems Utterly And Completely Wrong for `tcSyntaxOp` to take the
 continuation as a `thing_inside` argument. Not only is it extremely
 complicated, but it's also plain wrong.

 Why can't it just decompose the function type to produce a bunch of types
 to use as the expected types for the aguments?  No Notes explain.  The
 code makes my head spin.

 Richard, can't this all be radically simplified?

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14963#comment:8>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler

_______________________________________________
ghc-tickets mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-tickets
Reply | Threaded
Open this post in threaded view
|

Re: [GHC] #14963: ghci -fdefer-type-errors can't run IO action from another module

GHC - devs mailing list
In reply to this post by GHC - devs mailing list
#14963: ghci -fdefer-type-errors can't run IO action from another module
-------------------------------------+-------------------------------------
        Reporter:  elaforge          |                Owner:  (none)
            Type:  bug               |               Status:  new
        Priority:  high              |            Milestone:  8.4.2
       Component:  GHCi              |              Version:  8.4.1
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by simonpj):

 PS: using `WpFun` would mean you could return a single `HsWrapper` to wrap
 around the bind function, rather than returning wrappers for the function,
 the arguments, and the result.  See its use in `TcUnify.tc_sub_type_ds`.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14963#comment:9>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler

_______________________________________________
ghc-tickets mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-tickets
Reply | Threaded
Open this post in threaded view
|

Re: [GHC] #14963: ghci -fdefer-type-errors can't run IO action from another module

GHC - devs mailing list
In reply to this post by GHC - devs mailing list
#14963: ghci -fdefer-type-errors can't run IO action from another module
-------------------------------------+-------------------------------------
        Reporter:  elaforge          |                Owner:  (none)
            Type:  bug               |               Status:  new
        Priority:  high              |            Milestone:  8.4.2
       Component:  GHCi              |              Version:  8.4.1
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by goldfire):

 There's always room for simplification, of course, but I think the room
 here is limited. This whole mechanism came into being when `ExpType`s were
 introduced. `ExpType`s are "holes" -- places to write a type once we infer
 it; they replaced `SigmaTv` tyvars that were used previously. I forget
 what aspect of `ExpType`s specifically forced the rewrite of rebindable
 syntax, but I do remember that this was more-or-less forced.

 The reason for the complication is that we want to allow for the
 possibility that `(>>=) :: blah -> (forall x. x -> x) -> wurble`, where
 the arguments might have a higher-rank type. This, in turn, requires
 skolemization while type-checking. That problem with the current setup is
 that the two arguments are checked in the same `thing_inside`, where they
 should really be in ''different'' contexts. But that would make the whole
 scheme even more complicated.

 So I'm a bit stuck really on how you would want to simplify this.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14963#comment:10>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler

_______________________________________________
ghc-tickets mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-tickets
Reply | Threaded
Open this post in threaded view
|

Re: [GHC] #14963: ghci -fdefer-type-errors can't run IO action from another module

GHC - devs mailing list
In reply to this post by GHC - devs mailing list
#14963: ghci -fdefer-type-errors can't run IO action from another module
-------------------------------------+-------------------------------------
        Reporter:  elaforge          |                Owner:  (none)
            Type:  bug               |               Status:  new
        Priority:  high              |            Milestone:  8.4.2
       Component:  GHCi              |              Version:  8.4.1
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by goldfire):

 After a long discussion of design possibilities, Simon and I came to the
 following:

 1. The current design is broken, as described in this ticket.

 2. If we want to handle all rebindable syntax in a general fashion, we
 were unable to come up with anything simpler than the "impenetrable" code
 that exists. And, indeed, to fix the current flaw would likely require
 adding `HList`s or some such, making it even worse.

 3. Much of the current complication comes from the handling of `>>=`,
 which has an intricate type. Specifically, we need `(>>=) :: ty1 -> (ty2
 -> ty3) -> ty4`. However, it would also be quite cool if something like
 `(>>=) :: ty1 -> (forall a. ty2 -> ty3) -> ty4` were allowed. This
 effectively means that a `<-` operator in a `do` could bind an existential
 variable without using a pattern-match. And, if the user wrote `(>>=)`
 literally (without `do`), then this would indeed be possible. So it would
 be nice.

   The complication specifically stems from the fact that the code
 processing `BindStmt`s needs to know `ty2` and `ty3`, so we must decompose
 the type of `(>>=)`'s second argument. In order to do this, we need to
 skolemize any `forall`d variables, and skolemization requires an
 implication constraint, causing the bug in this ticket.

 4. Rebindable syntax that decomposes list constructors suffers a similar
 fate, but that's not nearly as painful as `(>>=)`.

 Though I'm still not fully convinced, we resolved to make the treatment of
 rebindable syntax simpler and less general. Specifically:

 a. Reduce `SyntaxOpType` to have two constructors: `SynAny ::
 SyntaxOpType` and `SynType :: ExpType -> SyntaxOpType`.

 b. Make new functions `tcBindOp`, `tcFromListOp`, and `tcFromListNOp` that
 handle the special cases for `(>>=)` and the list functions. These won't
 use general mechanisms, but just be a bit repetitive with `tcSyntaxOp`.

 c. The `SynRho` case of `tcSyntaxOp` will be dropped. Instead, clients of
 `tcSyntaxOp` that need rho-types will arrange to instantiate/skolemize the
 sigma-types that `tcSyntaxOp` provides as needed. This will duplicate
 code, but it means that `tcSyntaxOp` no longer needs to be written in CPS
 style. It will also allow this ticket to be resolved.

 d. This still won't handle cases like `fromListN :: (forall a. Int) -> [b]
 -> c`, where one parameter of a bit of rebindable syntax has a known type,
 but that known type might be redundantly quantified. Handling such a case
 would require CPSing again, and so we won't. This means that rebindable
 syntax will be a bit less expressive than the manual has heretofore
 promised. But the only lost cases are surely of the form above, where
 there is an unused quantified type variable. We can arrange for a suitable
 error message in these cases. This change will require a user manual
 update.

 e. When all this is done, the extra flexibility in the `SyntaxExpr` type
 -- with its argument wrappers and result wrapper -- won't be needed.
 Instead, `tcSyntaxOp` can return a plain old `HsExpr`, suitably wrapped.
 Accommodations will have to be made in `BindStmt` and the places where
 list operators might crop up to store extra `HsWrapper`s to be applied to
 arguments.

 f. A Note will be placed near `tcSyntaxOp` and the bind/list functions
 describing this design plan. If, in the future, we want more rebindable
 syntax, it might encourage us to re-adopt the more general -- but more
 complicated -- scheme currently in place.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14963#comment:11>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler

_______________________________________________
ghc-tickets mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-tickets
Reply | Threaded
Open this post in threaded view
|

Re: [GHC] #14963: ghci -fdefer-type-errors can't run IO action from another module

GHC - devs mailing list
In reply to this post by GHC - devs mailing list
#14963: ghci -fdefer-type-errors can't run IO action from another module
-------------------------------------+-------------------------------------
        Reporter:  elaforge          |                Owner:  (none)
            Type:  bug               |               Status:  new
        Priority:  high              |            Milestone:  8.4.2
       Component:  GHCi              |              Version:  8.4.1
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by elaforge):

 This is just a peanut-gallery comment, so forgive the naivety, but my
 impression is that Idris treats `do` desugaring purely syntactically, so
 e.g. you don't even need a Monad class or the expected types, just
 something called (>>=) and pure in scope.  Idris of course does a lot of
 things fundamentally differently, not the least of which is type-directed
 name overloading, but that seems orthogonal.  What's the problem with
 treating `do` as a syntax macro before even getting to typechecking?

 I gather the problem above is all rebindable syntax not just `do` and
 (>>=), but it made me curious about that one thing.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14963#comment:12>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler

_______________________________________________
ghc-tickets mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-tickets
Reply | Threaded
Open this post in threaded view
|

Re: [GHC] #14963: ghci -fdefer-type-errors can't run IO action from another module

GHC - devs mailing list
In reply to this post by GHC - devs mailing list
#14963: ghci -fdefer-type-errors can't run IO action from another module
-------------------------------------+-------------------------------------
        Reporter:  elaforge          |                Owner:  (none)
            Type:  bug               |               Status:  new
        Priority:  high              |            Milestone:  8.4.2
       Component:  GHCi              |              Version:  8.4.1
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by goldfire):

 I actually proposed doing exactly that when working this out with Simon.
 The problem is that doing so would ruin error messages, because we could
 report errors only with respect to the expanded syntax, instead of what
 the user actually wrote.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14963#comment:13>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler

_______________________________________________
ghc-tickets mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-tickets
Reply | Threaded
Open this post in threaded view
|

Re: [GHC] #14963: ghci -fdefer-type-errors can't run IO action from another module

GHC - devs mailing list
In reply to this post by GHC - devs mailing list
#14963: ghci -fdefer-type-errors can't run IO action from another module
-------------------------------------+-------------------------------------
        Reporter:  elaforge          |                Owner:  (none)
            Type:  bug               |               Status:  new
        Priority:  high              |            Milestone:  8.4.2
       Component:  GHCi              |              Version:  8.4.1
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by elaforge):

 Yeah, macros in general would need to store the original form and somehow
 get back to it for errors.  I'm sure this has been thought about quite a
 bit over the decades and the devil is in that "somehow."  I don't know
 anything about that previous work, so I'll leave it at that :)

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14963#comment:14>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler

_______________________________________________
ghc-tickets mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-tickets
Reply | Threaded
Open this post in threaded view
|

Re: [GHC] #14963: ghci -fdefer-type-errors can't run IO action from another module

GHC - devs mailing list
In reply to this post by GHC - devs mailing list
#14963: ghci -fdefer-type-errors can't run IO action from another module
-------------------------------------+-------------------------------------
        Reporter:  elaforge          |                Owner:  (none)
            Type:  bug               |               Status:  new
        Priority:  high              |            Milestone:  8.4.2
       Component:  GHCi              |              Version:  8.4.1
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by chak):

 Given that this didn't make it into 8.4.2, may I ask, what is the plan
 here?

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14963#comment:15>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler

_______________________________________________
ghc-tickets mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-tickets
Reply | Threaded
Open this post in threaded view
|

Re: [GHC] #14963: ghci -fdefer-type-errors can't run IO action from another module

GHC - devs mailing list
In reply to this post by GHC - devs mailing list
#14963: ghci -fdefer-type-errors can't run IO action from another module
-------------------------------------+-------------------------------------
        Reporter:  elaforge          |                Owner:  (none)
            Type:  bug               |               Status:  new
        Priority:  high              |            Milestone:  8.4.2
       Component:  GHCi              |              Version:  8.4.1
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by simonpj):

 As a short term fix how bad would it be to make `-fdefer-type-errors`
 incompatible with GHCi?

 We could apply that fix to HEAD (until we fix this ticket properly) and
 perhaps even to 8.4.3.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14963#comment:16>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler

_______________________________________________
ghc-tickets mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-tickets
Reply | Threaded
Open this post in threaded view
|

Re: [GHC] #14963: ghci -fdefer-type-errors can't run IO action from another module

GHC - devs mailing list
In reply to this post by GHC - devs mailing list
#14963: ghci -fdefer-type-errors can't run IO action from another module
-------------------------------------+-------------------------------------
        Reporter:  elaforge          |                Owner:  tdammers
            Type:  bug               |               Status:  new
        Priority:  high              |            Milestone:  8.4.2
       Component:  GHCi              |              Version:  8.4.1
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------
Changes (by tdammers):

 * owner:  (none) => tdammers


--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14963#comment:17>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler

_______________________________________________
ghc-tickets mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-tickets
Reply | Threaded
Open this post in threaded view
|

Re: [GHC] #14963: ghci -fdefer-type-errors can't run IO action from another module

GHC - devs mailing list
In reply to this post by GHC - devs mailing list
#14963: ghci -fdefer-type-errors can't run IO action from another module
-------------------------------------+-------------------------------------
        Reporter:  elaforge          |                Owner:  tdammers
            Type:  bug               |               Status:  new
        Priority:  high              |            Milestone:  8.4.2
       Component:  GHCi              |              Version:  8.4.1
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by tdammers):

 Replying to [comment:13 goldfire]:
 > I actually proposed doing exactly that when working this out with Simon.
 The problem is that doing so would ruin error messages, because we could
 report errors only with respect to the expanded syntax, instead of what
 the user actually wrote.

 My gut feeling (by all means correct me if I'm wrong!) is that this would
 still amount to a more elegant solution, everything considered. We would
 have to extend `HsSyn` to retain the original (sugared) notation, and
 treat such annotated syntax specially when printing error messages, but as
 far as type checking etc. are concerned, I would expect this to be mostly
 transparent.

 Personally, I wouldn't even mind getting error messages in desugared form,
 but I can understand if others feel strongly about this.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14963#comment:18>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler

_______________________________________________
ghc-tickets mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-tickets
Reply | Threaded
Open this post in threaded view
|

Re: [GHC] #14963: ghci -fdefer-type-errors can't run IO action from another module

GHC - devs mailing list
In reply to this post by GHC - devs mailing list
#14963: ghci -fdefer-type-errors can't run IO action from another module
-------------------------------------+-------------------------------------
        Reporter:  elaforge          |                Owner:  tdammers
            Type:  bug               |               Status:  new
        Priority:  high              |            Milestone:  8.4.2
       Component:  GHCi              |              Version:  8.4.1
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by tdammers):

 Replying to [comment:16 simonpj]:
 > As a short term fix how bad would it be to make `-fdefer-type-errors`
 incompatible with GHCi?
 >
 > We could apply that fix to HEAD (until we fix this ticket properly) and
 perhaps even to 8.4.3.

 I wouldn't be surprised to find that this breaks someone's workflow. Maybe
 we could get some opinions on this from the community?

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14963#comment:19>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler

_______________________________________________
ghc-tickets mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-tickets
12