[GHC] #8751: Show parenthesised output of expressions in ghci

GHC ghc-devs at haskell.org
Sat Oct 29 10:23:09 UTC 2016


#8751: Show parenthesised output of expressions in ghci
-------------------------------------+-------------------------------------
        Reporter:  Iceland_jack      |                Owner:
            Type:  feature request   |               Status:  infoneeded
        Priority:  normal            |            Milestone:
       Component:  GHCi              |              Version:  7.6.3
      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:                    |
-------------------------------------+-------------------------------------
Description changed by Iceland_jack:

@@ -2,2 +2,2 @@
- users!),[#point1 (1)] precedence levels may vary between languages and
- then there are user-defined operators.
+ users!),[#point1 ¹][#point2 ²] precedence levels may vary between
+ languages and then there are user-defined operators.
@@ -9,1 +9,2 @@
- {{{
+
+ {{{#!hs
@@ -25,2 +26,6 @@
- [=#point1 (1)] [http://www.knosof.co.uk/cbook/accu06.html Developer
- beliefs about binary operator precedence]
+ [=#point1 ¹] [http://www.knosof.co.uk/cbook/accu06.html Developer beliefs
+ about binary operator precedence]
+ [=#point2 ²]
+ [http://ieeexplore.ieee.org/document/7548903/?platform=hootsuite Brace
+ Yourself] ([https://twitter.com/ieeesoftware/status/791882437295038464
+ tweet])

New description:

 Operator fixity can be a source of bugs (even for experienced
 users!),[#point1 ¹][#point2 ²] precedence levels may vary between
 languages and then there are user-defined operators.

 Attached is a patch for a ghci command allowing users to quickly
 parenthesise expressions as a sanity check (and as an alternative to using
 :info and parsing the result yourself). The command itself is activated
 with `:paren`:

 {{{#!hs
 ghci> :paren 2 + 10 * 4 / 3
 2 + ((10 * 4) / 3)
 ghci> :paren \a b → a == b || b && a == (b == a) || b
 \ a b -> (a == b) || ((b && (a == (b == a))) || b)
 ghci> :paren 5 + 1 `mod` 2
 5 + (1 `mod` 2)
 ghci> :paren 5 * 1 `mod` 2
 (5 * 1) `mod` 2
 }}}

 A friend of mine also pointed out that this could eventually be integrated
 into `haskell-mode` where the user could temporarily replace an expression
 with a parenthesised version or have different colours indicate different
 levels of logical nesting.

 [=#point1 ¹] [http://www.knosof.co.uk/cbook/accu06.html Developer beliefs
 about binary operator precedence]
 [=#point2 ²]
 [http://ieeexplore.ieee.org/document/7548903/?platform=hootsuite Brace
 Yourself] ([https://twitter.com/ieeesoftware/status/791882437295038464
 tweet])

--

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


More information about the ghc-tickets mailing list