Opened 7 years ago

Closed 13 months ago

#1518 closed feature request (wontfix)

Make it possible to evaluate monadic actions when assigning record fields (<-)

Reported by: adde@… Owned by:
Priority: normal Milestone:
Component: Compiler Version: 6.6.1
Keywords: Cc: hackage.haskell.org@…
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Difficulty: Unknown
Test Case: Blocked By:
Blocking: Related Tickets:

Description

It is currently not possible to build records from values resulting from monadic actions while still using the field-specifiers.

foo :: IO Int
...

data Bar = Bar {

barFoo
Int
}

buildBar :: IO ()
buildBar = do

return Bar {

barFoo <- foo --Evaluate foo to get the Int-value

}

I've found two possible ways of doing this:

1) Using temporaries to evaluate the actions before assigning which doubles the number of lines:
tmp <- foo
return Bar {

barFoo = tmp

}

2) Lifting the record constructor which prevents you from using field specifiers (and you really need field specifiers when dealing with larger records):
liftM Bar foo

Change History (6)

comment:1 Changed 7 years ago by chevalier@…

If you wrote:

return Bar {
 barFoo <- foo
 barQuux <- quux
}

which do you think should be executed first -- computation foo or computation quux?

comment:2 Changed 7 years ago by igloo

  • Milestone set to _|_

This is being discussed on the Haskell' list:
http://www.haskell.org/pipermail/haskell-prime/2007-July/002265.html

comment:3 Changed 6 years ago by simonmar

  • Architecture changed from Unknown to Unknown/Multiple

comment:4 Changed 6 years ago by simonmar

  • Operating System changed from Unknown to Unknown/Multiple

comment:5 Changed 15 months ago by morabbin

  • Type of failure set to None/Unknown

Bump; still relevant? Seems a bit iffy to me.

comment:6 Changed 13 months ago by liyang

  • Cc hackage.haskell.org@… added
  • Resolution set to wontfix
  • Status changed from new to closed

Is this really necessary now that we have RecordWildCards?, NamedFieldPuns? and Applicative? (All of which were mentioned in the Haskell' discussion.)

Note: See TracTickets for help on using tickets.