tag:blogger.com,1999:blog-6454006.post7330748852526484064..comments2024-01-16T14:32:49.175+00:00Comments on Arcane Sentiment: Pipe for functionsArcane Sentimenthttp://www.blogger.com/profile/04144052171693893368noreply@blogger.comBlogger8125tag:blogger.com,1999:blog-6454006.post-89305488982591142922011-08-13T08:49:09.727+00:002011-08-13T08:49:09.727+00:00postfix is nice because it transforms the input on...postfix is nice because it transforms the input on the left into the output on the right.patchworkZombiehttps://www.blogger.com/profile/18279408952877283952noreply@blogger.comtag:blogger.com,1999:blog-6454006.post-46185608798862702312011-03-03T03:42:40.963+00:002011-03-03T03:42:40.963+00:00(f x □ y □ z) doesn't do what it looks like, t...(f x □ y □ z) doesn't do what it looks like, though — it's (op f x _ y z), not (op f x _ y _ z). (I take your point that □ handles more than just the 2-argument case, but I don't think it's as easy as λ or op.)Arcane Sentimenthttps://www.blogger.com/profile/04144052171693893368noreply@blogger.comtag:blogger.com,1999:blog-6454006.post-11297454127160316432011-02-27T19:38:32.099+00:002011-02-27T19:38:32.099+00:00Nuh uh, it handles (f x □ y □ z) too. Two partial ...Nuh uh, it handles (f x □ y □ z) too. Two partial arguments next to each other is a bit problematic, but you can do:<br /><br />(f x □) □ y<br /><br />which, admittedly, might be pushing the boundaries of readability.<br /><br />Yes, that has been done in an Emacs mode before; Agda, for instance, is primarily written with a modified version of the TeX input method, such that \to turns into a right-arrow, as well as \forall and the like.ehirdhttps://www.blogger.com/profile/01274306998660980484noreply@blogger.comtag:blogger.com,1999:blog-6454006.post-49185588882188297792011-02-27T01:29:05.753+00:002011-02-27T01:29:05.753+00:00Unicode is tempting, especially for ∘→⇒ and ∈⊆∩∪ a...Unicode is tempting, especially for ∘→⇒ and ∈⊆∩∪ and ≤≥≠∧∨ and of course λ. It's a bit of an input problem, though. Maybe an editor could automatically convert ASCII equivalents to Unicode, e.g. -> to →. This could be easily done in an Emacs mode; I wonder if it has?<br /><br />That □ operator only handles two-argument partial application, but that's still a substantial fraction. I'm not sure if it's more readable than prefix flip.Arcane Sentimenthttps://www.blogger.com/profile/04144052171693893368noreply@blogger.comtag:blogger.com,1999:blog-6454006.post-81077667266329243702011-02-25T21:02:08.948+00:002011-02-25T21:02:08.948+00:00With a dab of Unicode, we can solve this problem n...With a dab of Unicode, we can solve this problem nicely in Haskell:<br /><br /><br />type Socket = ()<br /><br />infixr 7 |><br />(|>) = flip (.)<br /><br />infixl 8 □<br />(□) = flip<br /><br />receive :: Socket -> String<br />receive _ = "a message"<br /><br />decrypt :: String -> String -> String<br />decrypt s _ = reverse s<br /><br />handleMessage :: String -> String<br />handleMessage s = "Handling: " ++ s<br /><br />socket :: Socket<br />socket = ()<br /><br />key :: String<br />key = ""<br /><br />example :: Socket -> String<br />example = receive |> decrypt □ key |> handleMessage<br /><br />If some of the functions are monadic, all you need is a different operator -- in fact, Haskell already has such an operator (>>=).ehirdhttps://www.blogger.com/profile/01274306998660980484noreply@blogger.comtag:blogger.com,1999:blog-6454006.post-79540117218014491222010-12-16T00:59:03.533+00:002010-12-16T00:59:03.533+00:00Yeah, this is one of two things I find surprisingl...Yeah, this is one of two things I find surprisingly convenient about standard OO languages. The other is class scope, which greatly reduces name collisions. Order is superficial enough that it can be handled in other ways (e.g. the pipe operator), but naming is hard.Arcane Sentimenthttps://www.blogger.com/profile/04144052171693893368noreply@blogger.comtag:blogger.com,1999:blog-6454006.post-61522907193348610542010-12-15T17:32:00.961+00:002010-12-15T17:32:00.961+00:00Functional (by this I mean prefer to return new va...Functional (by this I mean prefer to return new values over side-effects) C family OO code can actually look like this.<br /><br />For example<br /><br />someObject.asCollection().reverse().map(foo).reduce(bar)<br /><br />Looking at this code is painful to me (as my first experience with any language with a syntax like this was C++, which has scarred me for life), but it does have the properties that you suggest.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-6454006.post-82404254148286638842010-09-07T08:35:44.131+00:002010-09-07T08:35:44.131+00:00Or you simply use a concatenative language - like ...Or you simply use a concatenative language - like Factor (http://www.factorcode.org).x6j8xhttps://www.blogger.com/profile/03954597476893503292noreply@blogger.com