tag:blogger.com,1999:blog-5089773352404981635.post2212287976509080392..comments2023-10-04T08:15:13.812-07:00Comments on Daily scala: =>? type alias for PartialFunctionAnonymoushttp://www.blogger.com/profile/07600430363435495915noreply@blogger.comBlogger4125tag:blogger.com,1999:blog-5089773352404981635.post-67384581519353857022010-02-19T08:48:43.608-08:002010-02-19T08:48:43.608-08:00I still say that =?> scans better visually. And...I still say that =?> scans better visually. And it has embedded meaning: if you pass this to something that's expecting a Function1, you may have a nice mushroom cloud in the middle of things!Kris Nuttycombehttps://www.blogger.com/profile/06347383351250086727noreply@blogger.comtag:blogger.com,1999:blog-5089773352404981635.post-36081277967640512572010-02-19T03:56:25.098-08:002010-02-19T03:56:25.098-08:00It looks like if you add a : that changes the asso...It looks like if you add a : that changes the associativity:<br /><br />scala> type =>?:[-A, +B] = PartialFunction[A, B]<br />defined type alias $eq$greater$qmark$colon<br /><br />scala> class X { val x : Int =>?: Unit =>?: Any = null }<br />defined class X<br /><br />scala> new X().x <br />res2: =>?:[Int,=>?:[Unit,Any]] = nullAnonymoushttps://www.blogger.com/profile/07600430363435495915noreply@blogger.comtag:blogger.com,1999:blog-5089773352404981635.post-79984572055080861912010-02-19T03:49:14.292-08:002010-02-19T03:49:14.292-08:00To make what inkytonik said clearer, consider this...To make what inkytonik said clearer, consider this:<br /><br />A => B => C<br />A =>? B =>? C<br /><br />They translate, respectively, into:<br /><br />Function1[A, Function1[B, C]]<br />PartialFunction[PartialFunction[A, B], C]Danielhttps://www.blogger.com/profile/07505997833685327219noreply@blogger.comtag:blogger.com,1999:blog-5089773352404981635.post-70405386260483565582010-02-19T03:09:55.226-08:002010-02-19T03:09:55.226-08:00A nice alias indeed, but with one trap. The built...A nice alias indeed, but with one trap. The built-in => is right associative whereas the one defined above will be left associative. This is one reason why the latter was removed from Predef after making it in there at one stage.inkytonikhttps://www.blogger.com/profile/06529076679965968103noreply@blogger.com