[GHC] #14975: Refactor (Maybe Coercion)

#14975: Refactor (Maybe Coercion) -------------------------------------+------------------------------------- Reporter: tdammers | Owner: (none) Type: task | Status: new Priority: normal | Milestone: Component: Compiler | Version: Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: #11735 Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- As discussed here: https://phabricator.haskell.org/D4395#inline-34607 Define a type {{{#!hs data MCoercion = MRefl | MCo Coercion }}} This is isomorphic to {{{Maybe Coercion}}} but useful in a number of places, and super-helpful documentation. (eg {{{MRefl}}} is much more perspicuous than {{{Nothing}}}. Define this in {{{Coercion.hs}}} I think. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14975 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14975: Refactor (Maybe Coercion) -------------------------------------+------------------------------------- Reporter: tdammers | Owner: (none) Type: task | Status: new Priority: normal | Milestone: Component: Compiler | Version: Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #11735 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by tdammers): A few questions that pop up: - Shouldn't this go in `TyCoRep.hs`, and then be re-exported from `Coercion.hs`, like the other coercion-related types? - Defined like this (`*` rather than `* -> *`), we'll miss out on `Functor`, `Applicative`, `Alternative`, etc.; are we going to regret this? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14975#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14975: Refactor (Maybe Coercion) -------------------------------------+------------------------------------- Reporter: tdammers | Owner: (none) Type: task | Status: new Priority: normal | Milestone: Component: Compiler | Version: Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #11735 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by goldfire): Yes, it makes sense to put this in `TyCoRep`, so that only some modules gain access to the constructors. I'm not so worried about `Functor` and friends. If this turns out to bite, we can always fix it later. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14975#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14975: Refactor (Maybe Coercion) -------------------------------------+------------------------------------- Reporter: tdammers | Owner: (none) Type: task | Status: new Priority: normal | Milestone: Component: Compiler | Version: Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #11735 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by tdammers):
I'm not so worried about Functor and friends. If this turns out to bite, we can always fix it later.
Oh, I wouldn't expect it to actually bite, just to not give us some of the useful instances that `Maybe` has, which might make it a bit more awkward to work with. But it's probably not going to be a problem. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14975#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14975: Refactor (Maybe Coercion) -------------------------------------+------------------------------------- Reporter: tdammers | Owner: (none) Type: task | Status: new Priority: normal | Milestone: Component: Compiler | Version: Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #11735 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by tdammers): Turns out there are a few places in the code that exploit `Maybe`'s `Monad` instance (using `do` notation). I'll keep those as `Maybe` for now and see where I end up. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14975#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14975: Refactor (Maybe Coercion) -------------------------------------+------------------------------------- Reporter: tdammers | Owner: (none) Type: task | Status: new Priority: normal | Milestone: Component: Compiler | Version: Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #11735 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by goldfire): How is this going? I don't mean to steal it out from under you, but if this is caught behind other priorities, it would make a great warm-up exercise for my GSoC student. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14975#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14975: Refactor (Maybe Coercion) -------------------------------------+------------------------------------- Reporter: tdammers | Owner: (none) Type: task | Status: new Priority: normal | Milestone: Component: Compiler | Version: Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #11735 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by tdammers): I've been doing some work on this in between other stuff, but haven't gotten very far yet. I have a `MCoercion` type in place (which is trivial), and my first approach was to just naively replace all `Maybe Coercion`s with `MCoercion` and then follow the compiler errors. However, this doesn't work out all that well, because some of those `Maybe`s are actually morally justified as such (i.e., `Nothing` does not not mean "this is a Refl coercion", but it actually means "nothing found" / "failure"). I was going to go through the code and look at all occurrences individually, but haven't gotten around to this yet. If someone wants to take this off me, and do the work for free, I say go ahead, I'm not emotionally invested in this. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14975#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14975: Refactor (Maybe Coercion) -------------------------------------+------------------------------------- Reporter: tdammers | Owner: (none) Type: task | Status: new Priority: normal | Milestone: Component: Compiler | Version: Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #11735 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by ningning): Hi there. This is Ningning. I am one of the students of GSoC this year under advised by Richard. Find more information about [https://summerofcode.withgoogle.com/projects/#5851493949767680/ my proposal]. Thanks to tdammers, I am taking this ticket as my warm-up exercise :). -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14975#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

Hi there. This is Ningning. I am one of the students of GSoC this year under advised by Richard. Find more information about [https://summerofcode.withgoogle.com/projects/#5851493949767680/ my
#14975: Refactor (Maybe Coercion) -------------------------------------+------------------------------------- Reporter: tdammers | Owner: (none) Type: task | Status: new Priority: normal | Milestone: Component: Compiler | Version: Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #11735 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by tdammers): Replying to [comment:7 ningning]: proposal].
Thanks to tdammers, I am taking this ticket as my warm-up exercise :).
Great! The code I have so far is on the GHC git repo, in the wip/T14975 branch. Though not strictly necessary for this, you may want to also look into tickets #11735, #14737 and #15019 for context. Let us know if there's anything else you need. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14975#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14975: Refactor (Maybe Coercion) -------------------------------------+------------------------------------- Reporter: tdammers | Owner: (none) Type: task | Status: patch Priority: normal | Milestone: Component: Compiler | Version: Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #11735 | Differential Rev(s): Phab:D4699 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: new => patch * differential: => Phab:D4699 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14975#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14975: Refactor (Maybe Coercion)
-------------------------------------+-------------------------------------
Reporter: tdammers | Owner: (none)
Type: task | Status: patch
Priority: normal | Milestone:
Component: Compiler | Version:
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: #11735 | Differential Rev(s): Phab:D4699
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Ben Gamari

#14975: Refactor (Maybe Coercion) -------------------------------------+------------------------------------- Reporter: tdammers | Owner: (none) Type: task | Status: closed Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #11735 | Differential Rev(s): Phab:D4699 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: patch => closed * resolution: => fixed * milestone: => 8.6.1 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14975#comment:11 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14975: Refactor (Maybe Coercion)
-------------------------------------+-------------------------------------
Reporter: tdammers | Owner: (none)
Type: task | Status: closed
Priority: normal | Milestone: 8.6.1
Component: Compiler | Version:
Resolution: fixed | Keywords:
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: #11735 | Differential Rev(s): Phab:D4699
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Richard Eisenberg
participants (1)
-
GHC