packages feed

egison-3.8.2: lib/core/maybe.egi

;;;;;
;;;;;
;;;;; Maybe (Option)
;;;;;
;;;;;

(define $Nothing {})
(define $Just (lambda [$x] {x}))

(define $nothing (pattern-function [] <nil>))
(define $just (pattern-function [$pat] <cons pat _>))

(define $maybe (lambda [$a] (list a)))

;(match-all (Just 1) (maybe integer) [(nothing) "error"]) ; {}
;(match-all (Just 1) (maybe integer) [(just $x) x]) ; {1}