Skip to content

is a collection of utility macros around match.

Notifications You must be signed in to change notification settings

hellerve/match-utils

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

match-utils

is a collection of utility macros around match.

WIP, the scoring has to be verified.

Usage

; let-match lets you do a match bind
(let-match [(Maybe.Just x) (Array.nth &[@"hi"] 0)]
  (println* x)) ; => "hi"

; defn-match allows you to write pattern-matching functions
; dispatch is optimized, but i don’t know how robustly
(deftype Num
  (I [Int])
  (D [Double]))

(use Num)
(MatchUtils.defn-match add-num
  [(I x) (I y)] (I (+ x y))
  [(D x) (D y)] (D (+ x y))
  [(D x) (I y)] (D (+ x (from-int y)))
  [(I x) (D y)] (D (+ (from-int x) y)))

Have fun!

About

is a collection of utility macros around match.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published