Opened 10 years ago

Closed 8 years ago

#3993 closed feature request (wontfix)

allow implicit parameter bindings in patterns

Reported by: aavogt Owned by:
Priority: normal Milestone: 7.2.1
Component: Compiler Version: 6.12.1
Keywords: Cc: vogt.adam@…
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

It could work like such:

main = do
    ?conts <- getContents
    fun

fun :: (?conts :: String) -> IO ()
fun = ...

becoming something like

main = do
    conts <- getContents
    let ?conts = conts
    fun

Of course there are still questions regarding interactions with pattern guards and view patterns (whether those variables should be in scope for other guards, or for view patterns that follow).

This interaction with view patterns (and pattern guards), should likely elicit a warning:

   let ?x = 1 in
   let f ?x ((?x +) -> y) = y in
   f 0 0

As it might be expected that this expression should be 1, while I think it should evaluate to 0.

This probably would lead to more syntax stealing, but it seems unlikely that there would be code that enables -XImplicitParams that does stuff like:

x ?y = ...

Expecting to define the function `?', rather than binding the implicit parameter ?y.

Change History (7)

comment:1 Changed 10 years ago by aavogt

Summary: allow implicit parameter bindings in patternseeeallow implicit parameter bindings in patterns

comment:2 Changed 10 years ago by aavogt

Cc: vogt.adam@… added

comment:3 Changed 10 years ago by igloo

Milestone: 6.14.1

comment:4 Changed 10 years ago by simonpj

To me this seems like a perfectly reasonable suggestion, but even apart from the work of designing the feature and implementing it, it constitutes one more little complexity in the compiler. So it's likely to languish in the "nice to have" pile and end up not getting done, unless you can assemble a consensus that it would be a Good Thing and that Many People Would Like It.

Simon

comment:5 Changed 9 years ago by igloo

Milestone: 7.0.17.0.2

comment:6 Changed 9 years ago by igloo

Milestone: 7.0.27.2.1

comment:7 Changed 8 years ago by igloo

Resolution: wontfix
Status: newclosed

This seems to have little support, so I'll close the ticket.

Note: See TracTickets for help on using tickets.