[GHC] #10344: Make BranchList simpler

#10344: Make BranchList simpler -------------------------------------+------------------------------------- Reporter: goldfire | Owner: goldfire Type: task | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.11 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Blocked By: Test Case: | Related Tickets: Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- As Adam Gundry suggested, `BranchList` could be made much simpler by actually storing a list in the `Branched` case. Though, as I'm thinking about it, what's better about a real list over a `BranchList`? We're more familiar with it... but perhaps adding a `Foldable` instance for `BranchList` would solve the problem. In any case, this ticket is to record the desire for improvement. If Adam is up to it, he may fix this with Phab:D841. Otherwise, I'll get to it. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10344 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10344: Make BranchList simpler -------------------------------------+------------------------------------- Reporter: goldfire | Owner: goldfire Type: task | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.11 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Changes (by adamgundry): * cc: adamgundry (added) Comment: A `Foldable` instance for `BranchList` might well simplify things, but I feel it would be simpler still for `BranchList` to be non-recursive, something like {{{ data BranchList a br where UnbranchedList :: a -> BranchList a Unbranched BranchedList :: [a] -> BranchList a Branched }}} You are welcome to disagree, though. :-) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10344#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10344: Make BranchList simpler -------------------------------------+------------------------------------- Reporter: goldfire | Owner: goldfire Type: task | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.11 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by simonpj): Yes yes! Simple is good! Needs a comment to stress that in the `BranchedList` case the list may legitimately be empty. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10344#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10344: Make BranchList simpler -------------------------------------+------------------------------------- Reporter: goldfire | Owner: goldfire Type: task | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.11 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by goldfire): Replying to [comment:2 simonpj]:
Yes yes! Simple is good! Needs a comment to stress that in the `BranchedList` case the list may legitimately be empty.
But a `BranchList Branched` currently still can't be empty -- Adam's empty CTF patch uses the `Maybe (CoAxiom Branched)` approach to deal with empty CTFs. Consumers of `fromBranchList` assume they're getting a non-empty list. So, we could do {{{ data BranchList a br where OneBranch :: a -> BranchList a Unbranched ManyBranches :: a -> [a] -> BranchList a Branched -- requires at least one element }}} This is certainly simpler than the current story. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10344#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10344: Make BranchList simpler -------------------------------------+------------------------------------- Reporter: goldfire | Owner: goldfire Type: task | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.11 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by simonpj): But he uses `Maybe (CoAxiom Branched)` because branch-lists could not previously represent empty lists. Once they can we can get rid of the `Maybe`. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10344#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10344: Make BranchList simpler -------------------------------------+------------------------------------- Reporter: goldfire | Owner: goldfire Type: task | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.11 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by goldfire): But looking at Adam's code, I think changing it from using `Maybe` would make it more complex, not less. (I agreed with you about avoiding `Maybe` here originally, but inspection of the code encouraged me to change my mind.) In any case, I don't feel too strongly here. Ask once more, and I'll agree with you. :) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10344#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC