mirror of
https://github.com/correl/calrissian.git
synced 2024-11-23 19:19:57 +00:00
Various formatting tweaks.
This commit is contained in:
parent
47d70c8772
commit
69be73e4a3
4 changed files with 28 additions and 20 deletions
|
@ -8,4 +8,6 @@
|
||||||
(funcall f x))
|
(funcall f x))
|
||||||
|
|
||||||
(defun return (x) x)
|
(defun return (x) x)
|
||||||
(defun fail (x) (throw (tuple 'error x)))
|
|
||||||
|
(defun fail (x)
|
||||||
|
(throw (tuple 'error x)))
|
||||||
|
|
|
@ -10,5 +10,8 @@
|
||||||
(((tuple 'just x) f)
|
(((tuple 'just x) f)
|
||||||
(funcall f x)))
|
(funcall f x)))
|
||||||
|
|
||||||
(defun return (x) (tuple 'just x))
|
(defun return (x)
|
||||||
(defun fail (_) 'nothing)
|
(tuple 'just x))
|
||||||
|
|
||||||
|
(defun fail (_)
|
||||||
|
'nothing)
|
||||||
|
|
|
@ -9,9 +9,11 @@
|
||||||
((_) 'undefined))
|
((_) 'undefined))
|
||||||
|
|
||||||
(defun do-transform
|
(defun do-transform
|
||||||
((monad (cons h '())) h)
|
((monad (cons h '()))
|
||||||
((monad (cons (list f '<- m) t)) (list '>>= monad
|
h)
|
||||||
|
((monad (cons (list f '<- m) t))
|
||||||
|
(list '>>= monad
|
||||||
m
|
m
|
||||||
(list 'lambda (list f) (do-transform monad t))))
|
(list 'lambda (list f) (do-transform monad t))))
|
||||||
((monad (cons h t)) (list '>> monad h (do-transform monad t)))
|
((monad (cons h t))
|
||||||
)
|
(list '>> monad h (do-transform monad t))))
|
||||||
|
|
|
@ -9,27 +9,28 @@
|
||||||
;; Report exported function arities as (arity - 1) to account for
|
;; Report exported function arities as (arity - 1) to account for
|
||||||
;; the extra argument supplied to tuple modules
|
;; the extra argument supplied to tuple modules
|
||||||
(let ((fix-info (lambda (info-plist)
|
(let ((fix-info (lambda (info-plist)
|
||||||
(let* ((exports (: proplists get_value 'exports info-plist))
|
(let* ((exports (proplists:get_value 'exports info-plist))
|
||||||
(fix-arity (match-lambda
|
(fix-arity (match-lambda
|
||||||
;; module_info is added by the compiler and therefore remains as-is
|
;; module_info is added by the compiler and therefore remains as-is
|
||||||
(((tuple 'module_info arity)) (tuple 'module_info arity))
|
(((tuple 'module_info arity)) (tuple 'module_info arity))
|
||||||
(((tuple fun arity)) (tuple fun (- arity 1)))))
|
(((tuple fun arity)) (tuple fun (- arity 1)))))
|
||||||
(info-dict (: dict from_list info-plist))
|
(info-dict (dict:from_list info-plist))
|
||||||
(new-dict (: dict store 'exports (: lists map fix-arity exports) info-dict))
|
(new-dict (dict:store 'exports (lists:map fix-arity exports) info-dict))
|
||||||
(new-plist (: dict to_list new-dict)))
|
(new-plist (dict:to_list new-dict)))
|
||||||
new-plist))))
|
new-plist))))
|
||||||
(funcall fix-info (module-info module))))
|
(funcall fix-info (module-info module))))
|
||||||
((module) (call module 'module_info)))
|
((module)
|
||||||
|
(call module 'module_info)))
|
||||||
|
|
||||||
(defun module-info (module key)
|
(defun module-info (module key)
|
||||||
(: proplists get_value key (module-info module)))
|
(proplists:get_value key (module-info module)))
|
||||||
|
|
||||||
(defun implements? (behaviour module)
|
(defun implements? (behaviour module)
|
||||||
(let* ((exports (module-info module 'exports))
|
(let* ((exports (module-info module 'exports))
|
||||||
(exported? (lambda (definition) (: lists member definition exports))))
|
(exported? (lambda (definition) (lists:member definition exports))))
|
||||||
(: lists all exported?
|
(lists:all exported?
|
||||||
(call behaviour 'behaviour_info 'callbacks))))
|
(call behaviour 'behaviour_info 'callbacks))))
|
||||||
|
|
||||||
(defun exports? (definition module)
|
(defun exports? (definition module)
|
||||||
(: lists member definition
|
(lists:member definition
|
||||||
(module-info module 'exports)))
|
(module-info module 'exports)))
|
Loading…
Reference in a new issue