Skip to content

clanhr/result

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

63 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ClanHR's Result Library Build Status

Clojars Project

This component represents a way to represent function return values, with a success/failure semantic. Also has several useful macros for dealing with functions that use this component. Example of usage:

(defn foo [] (result/success {:some-data "Hello"}))
(defn notgood [] (result/failure "Not good"))

(if (result/succeeded? foo)
  (println "ok")
  (println "nok"))

The following macros will only run the body if the results succeed. If any result fails, that result will be the value of the expression.

(result/if-let [r1 foo]
  (println "ok")
  (println "nok"))

(result/on-success [r1 foo]
  (println "ok"))

(result/enforce-let [r1 notgood
                     r2 foo])
  (println "notgoof will be returned"))

(result/enforce-let [r1 notgood
                     r2 foo
                     r2 (result/success)])

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •