Re: [Haskell-cafe] Re: Re-order type (flip map)
Stephen Tetley schrieb: On 11 October 2010 00:00, Johannes Waldmann waldm...@imn.htwk-leipzig.de wrote: My point was: you need to find/define two operators, not just one. Sure, I need flip ($) and flip (.) Since the Prelude forgot to define these (and flip map), the question was: are there established names for these two operators? (#) was quite established for flip ($) around 2000 - its in a couple of papers that appeared at the PADL conferences - one written by Erik Meijer, Daan Leijen and (I think) James Hook on scripting Microsoft Agents with COM. The authors noted reverse application with (#) gave code a nice OO-like reading. The other was Peter Thiemann's Wash - (#) is again flip ($) and (##) is flipped compose. also in Functional Metapost. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Re-order type (flip map)
Dan Doel schrieb: On Sunday 10 October 2010 5:32:16 pm Johannes Waldmann wrote: I mean instead of h . g . f $ x I'd sometimes prefer x ? f ? g ? h but what are the ? Note, before anyone gets too excited about this, there are some built-in things about the language that make forward chaining less nice. For instance: (f $ \x - ...) /= (\x - ... ? f) (f $ do ...)/= (do ... ? f) http://www.haskell.org/haskellwiki/Direction_of_data_flow ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Re-order type (flip map)
On 11 October 2010 00:00, Johannes Waldmann waldm...@imn.htwk-leipzig.de wrote: My point was: you need to find/define two operators, not just one. Sure, I need flip ($) and flip (.) Since the Prelude forgot to define these (and flip map), the question was: are there established names for these two operators? (#) was quite established for flip ($) around 2000 - its in a couple of papers that appeared at the PADL conferences - one written by Erik Meijer, Daan Leijen and (I think) James Hook on scripting Microsoft Agents with COM. The authors noted reverse application with (#) gave code a nice OO-like reading. The other was Peter Thiemann's Wash - (#) is again flip ($) and (##) is flipped compose. Typographically I think these are a good fit, unfortunately they now might play badly with GHC's magic hash operator. Best wishes Stephen ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Re-order type (flip map)
The student has accidental given the arguments of map in the wrong order I am using for = flip map a lot, in code like for [ 1 .. 10 ] $ \ i - ... in fact that's one of my most dearly missed Prelude functions. Note that we have Control.Monad.forM forM [ 1 .. 10 ] $ \ i - do ... Oh, and while we're at it - are there standard notations for forward function composition and application? I mean instead of h . g . f $ x I'd sometimes prefer x ? f ? g ? h but what are the ? J.W. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Re-order type (flip map)
On Sun, Oct 10, 2010 at 6:32 PM, Johannes Waldmann waldm...@imn.htwk-leipzig.de wrote: Oh, and while we're at it - are there standard notations for forward function composition and application? I mean instead of h . g . f $ x I'd sometimes prefer x ? f ? g ? h but what are the ? import Control.Arrow something = f g h $ x -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Re-order type (flip map)
On 10 October 2010 22:32, Johannes Waldmann waldm...@imn.htwk-leipzig.dewrote: Oh, and while we're at it - are there standard notations for forward function composition and application? I mean instead of h . g . f $ x I'd sometimes prefer x ? f ? g ? h but what are the ? While asking you use the same symbol for function composition, and something like inverse function application. I don't think there exists an operator ?, such that h . g . f $ x is equivalent to x ? f ? g ? h. But you can simply define an inverse function application like the following and have a close enough alternative, ($$) :: a - (a - b) - b ($$) = flip ($) infixl 5 $$ Now the following two expression are identical, I suppose: h . g . f $ x x $$ f . g . h Cheers, Ozgur ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Re-order type (flip map)
No, wrong. I am speaking nonsense here. Of course one also needs to define a *forward* function composition operator to get the effect you originally wanted. My point was: you need to find/define two operators, not just one. That still holds :) Best, On 10 October 2010 23:47, Ozgur Akgun ozgurak...@gmail.com wrote: On 10 October 2010 22:32, Johannes Waldmann waldm...@imn.htwk-leipzig.dewrote: Oh, and while we're at it - are there standard notations for forward function composition and application? I mean instead of h . g . f $ x I'd sometimes prefer x ? f ? g ? h but what are the ? While asking you use the same symbol for function composition, and something like inverse function application. I don't think there exists an operator ?, such that h . g . f $ x is equivalent to x ? f ? g ? h. But you can simply define an inverse function application like the following and have a close enough alternative, ($$) :: a - (a - b) - b ($$) = flip ($) infixl 5 $$ Now the following two expression are identical, I suppose: h . g . f $ x x $$ f . g . h Cheers, Ozgur -- Ozgur Akgun ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Re-order type (flip map)
My point was: you need to find/define two operators, not just one. Sure, I need flip ($) and flip (.) Since the Prelude forgot to define these (and flip map), the question was: are there established names for these two operators? J. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Re-order type (flip map)
On Mon, Oct 11, 2010 at 00:51, Ozgur Akgun ozgurak...@gmail.com wrote: My point was: you need to find/define two operators, not just one. That still holds :) No it doesn't. f $ g $ h $ x == f (g (h x)) == f . g . h $ x == x $$ h $$ g $$ f if you have the correct associativity for ($$) --Max ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Re-order type (flip map)
On 10/10/10 7:00 PM, Johannes Waldmann wrote: My point was: you need to find/define two operators, not just one. Sure, I need flip ($) and flip (.) Since the Prelude forgot to define these (and flip map), the question was: are there established names for these two operators? I don't know how established it is, but ($) is a common name for flip($). Common, as in, I've seen three or so different people use it. IIRC, the F# name is (|) but triangles are far too nice of a name and are often used for other things (e.g., cons and snoc). For what it's worth, this is the T combinator--- in case thrushes give you any ideas for names. Personally I'm more likely to use T as a prefix combinator rather than as infix, and for that the ($ _) section is good enough for me. As for flip(.) we have () in Control.Arrow. -- Live well, ~wren ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Re-order type (flip map)
On Sunday 10 October 2010 5:32:16 pm Johannes Waldmann wrote: I mean instead of h . g . f $ x I'd sometimes prefer x ? f ? g ? h but what are the ? Note, before anyone gets too excited about this, there are some built-in things about the language that make forward chaining less nice. For instance: (f $ \x - ...) /= (\x - ... ? f) (f $ do ...)/= (do ... ? f) You need to add parentheses for the right sides, which defeats at least part of the point of ($). The second is even incompatible in two ways, because left-to-right impredicative instantiation seems to be back in GHC 7, and so: runST $ do ... will work, while (do ...) ? runST will be a type error, assuming it's just flip ($) with the usual type. -- Dan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Re-order type (flip map)
On Sun, Oct 10, 2010 at 4:47 PM, Ozgur Akgun ozgurak...@gmail.com wrote: On 10 October 2010 22:32, Johannes Waldmann waldm...@imn.htwk-leipzig.de wrote: Oh, and while we're at it - are there standard notations for forward function composition and application? I mean instead of h . g . f $ x I'd sometimes prefer x ? f ? g ? h but what are the ? While asking you use the same symbol for function composition, and something like inverse function application. I don't think there exists an operator ?, such that h . g . f $ x is equivalent to x ? f ? g ? h. infixl 9 ? x ? f = f x h . g . f $ x = h (g (f x)) = h (g (x ? f)) = h (x ? f ? g) = x ? f ? g ? h Luke ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe