Created
          February 8, 2010 21:04 
        
      - 
      
 - 
        
Save aboekhoff/298581 to your computer and use it in GitHub Desktop.  
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | (defn e-bind [f] | |
| (fn [v] | |
| (let [[e *v] (try [true (f v)] (catch Exception e [false (.toString e)]))] | |
| (if e *v (handler e *v f))))) | |
| ;; presumably this would do something constructive, and | |
| ;; probably expect more preceding state from preceding computations | |
| ;; in a domonad form | |
| (defn handler [s x f] | |
| (println "input was" s) | |
| (println "exception was" x) | |
| (println "next fn was " f) | |
| (println (str "... recovering")) | |
| (f #(println :safe-continuation))) | |
| ((e-bind #(%)) #(println "foo")) | |
| => | |
| foo | |
| ((e-bind #(%)) nil) | |
| => | |
| input was false | |
| exception was java.lang.NullPointerException | |
| next fn was #<user$eval__8118$fn__8120 user$eval__8118$fn__8120@7abccf9a> | |
| ... recovering | |
| :safe-continuation | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment