HNHacker News
TopNewBestAskShowJobs

rntz

2,169 karma · joined May 25, 2009

www.rntz.net email: http://www.google.com/recaptcha/mailhide/d?k=018XOhLYKe9NqLdmoSmt6HsQ==&c=mcxnT-9mQPQEL6wailXqNUHk3aPs4Jv1T3vTJsNNAkg=
submissionscomments
rntz··on Alan Kay: Worlds: Controlling the scope of side effects [pdf]
Coming from Haskell, this seems a lot like taking the entire state of the world, sans I/O, and just bundling it into a monad (or MonadPlus, etc). Powerful, but a bit of a blunt instrument compared to using a finer-grained technique. The backtracking use-case given of trying two keys to open a safe, for example, is straightfoward to solve with the List monad.

    import OutsideWorld (keyA, keyB, unlocksSafe)
    
    unlockSafe = do
        key <- [keyA, keyB]
        if unlocksSafe key then return key else mzero
Of course, in Haskell, this would be more idiomatically solved simply using filter; but it's a toy example after all.
← PreviousPage 15 of 15