Re: [GHC] #1518: Make it possible to evaluate monadic actions when assigning record fields (-)
#1518: Make it possible to evaluate monadic actions when assigning record fields (-) ---+ Reporter: [EMAIL PROTECTED] |Owner: Type: feature request | Status: new Priority: normal |Milestone: _|_ Component: Compiler| Version: 6.6.1 Severity: normal | Resolution: Keywords: | Difficulty: Unknown Os: Unknown | Testcase: Architecture: Unknown | ---+ Changes (by igloo): * milestone: = _|_ Comment: This is being discussed on the Haskell' list: http://www.haskell.org/pipermail/haskell-prime/2007-July/002265.html -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/1518 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler___ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
Re: [GHC] #1518: Make it possible to evaluate monadic actions when assigning record fields (-)
On Mon, 2007-07-09 at 23:28 +, GHC wrote: #1518: Make it possible to evaluate monadic actions when assigning record fields (-) ---+ Reporter: [EMAIL PROTECTED] |Owner: Type: feature request | Status: new Priority: normal |Milestone: Component: Compiler| Version: 6.6.1 Severity: normal | Resolution: Keywords: | Difficulty: Unknown Os: Unknown | Testcase: Architecture: Unknown | ---+ Comment (by [EMAIL PROTECTED]): If you wrote: {{{ return Bar { barFoo - foo barQuux - quux } }}} which do you think should be executed first -- computation foo or computation quux? -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/1518 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler I would expect them to be executed in the declared order, why? /Adde ___ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
Re: [GHC] #1518: Make it possible to evaluate monadic actions when assigning record fields (-)
On 7/9/07, Adde [EMAIL PROTECTED] wrote: On Mon, 2007-07-09 at 23:28 +, GHC wrote: #1518: Make it possible to evaluate monadic actions when assigning record fields (-) ---+ Reporter: [EMAIL PROTECTED] |Owner: Type: feature request | Status: new Priority: normal |Milestone: Component: Compiler| Version: 6.6.1 Severity: normal | Resolution: Keywords: | Difficulty: Unknown Os: Unknown | Testcase: Architecture: Unknown | ---+ Comment (by [EMAIL PROTECTED]): If you wrote: {{{ return Bar { barFoo - foo barQuux - quux } }}} which do you think should be executed first -- computation foo or computation quux? -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/1518 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler I would expect them to be executed in the declared order, why? But when? At the point when the return Bar{...} expression is demanded? OK, but then you're making the Bar constructor strict when it wouldn't be otherwise. But if you let Bar be lazy as it normally is, then you get effectful expressions being evaluated at unpredictable times (e.g., in my example, maybe the foo field will never be demanded and the quux field will be), which is generally considered harmful. Cheers, Tim -- Tim Chevalier* catamorphism.org *Often in error, never in doubt I haven't got the slightest idea how to change people, but still I keep a long list of prospective candidates just in case I should ever figure it out. --David Sedaris ___ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
[GHC] #1518: Make it possible to evaluate monadic actions when assigning record fields (-)
#1518: Make it possible to evaluate monadic actions when assigning record fields (-) -+-- Reporter: [EMAIL PROTECTED] | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler|Version: 6.6.1 Severity: normal | Keywords: Difficulty: Unknown | Os: Unknown Testcase: | Architecture: Unknown -+-- 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 -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/1518 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler___ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
Re: [GHC] #1518: Make it possible to evaluate monadic actions when assigning record fields (-)
#1518: Make it possible to evaluate monadic actions when assigning record fields (-) ---+ Reporter: [EMAIL PROTECTED] |Owner: Type: feature request | Status: new Priority: normal |Milestone: Component: Compiler| Version: 6.6.1 Severity: normal | Resolution: Keywords: | Difficulty: Unknown Os: Unknown | Testcase: Architecture: Unknown | ---+ Comment (by [EMAIL PROTECTED]): If you wrote: {{{ return Bar { barFoo - foo barQuux - quux } }}} which do you think should be executed first -- computation foo or computation quux? -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/1518 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler___ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
Re: [GHC] #1518: Make it possible to evaluate monadic actions when assigning record fields (-)
Hi Adde, #1518: Make it possible to evaluate monadic actions when assigning record fields It is currently not possible to build records from values resulting from monadic actions while still using the field-specifiers. This is quite a significant change to the language, which isn't precise enough. Perhaps if you discussed it on the haskell-cafe@ or haskell-prime@ mailing lists first you might be able to firm up what you are asking for, including the desugaring rules etc. You might also find that people have developed something to get round this. Thanks Neil ___ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs