6 ms·
I got the suspicion that Haskell notation was used because he'd written those commands in Haskell; could be wrong though.
by olliesaunders 17y ago
I got the suspicion that Haskell notation was used because he'd written those commands in Haskell; could be wrong though.
- nixme 17y agoThey're written in Perl. Take a look at the sources: tmp: http://conway.rutgers.edu/~ccshan/wiki/blog/posts/Higher-order_shell/tmp http://conway.rutgers.edu/~ccshan/wiki/blog/posts/Higher-ord... keep: http://conway.rutgers.edu/~ccshan/wiki/blog/posts/Higher-order_shell/keep http://conway.rutgers.edu/~ccshan/wiki/blog/posts/Higher-ord...
- tel 17y agoNo, I thought so at first as well, but later realized that he was doing it totally for documentation's purposes (well, and impact).
- jrockway 17y agoI don't think some of the things he writes, like "MonadIO m => m () -> IO ()" are generally possible, for example. There are specific instances of MonadIO (ErrorT, etc.) that have a function that does that, but MonadIO itself only has the liftIO function, which is "MonadIO m => IO a -> m a".
- tel 17y agoGood call. I agree in disagreeing with his type for 'keep'. I think he was aiming at the idea of "any computation which is liftable to an IO computation" instead of "computation which can be evaluated within an IO context". In my opinion, since 'keep' takes a function which is, in general, fully capable of any effectful action, it necessarily is of the type keep :: IO a -> ... but since it's roughly ignoring any potential return 'a', yet still evaluating the function repeatedly, the best type is something like keep :: IO a -> IO [()]
- jrockway 17y agoI think he actually meant "MonadIO m => m a -> m a". Anyway, if I were going to use Haskell-style type signatures in an article about shell scripts written in Perl, I would probably skip the whole typeclass and monad concept, and just say something like: keep :: Action -> Action This doesn't say much about the infinite nature of the process, unfortunately, but modeling effects as though they are pure functions just gets you into trouble anyway. His textual description is much more natural and easier to understand. Anyway, I like articles that combine both Perl and Haskell :) They make me feel less insane.