Various formatting tweaks.

This commit is contained in:
Duncan M. McGreggor 2015-05-19 23:30:19 -05:00
parent 47d70c8772
commit 69be73e4a3
4 changed files with 28 additions and 20 deletions

View file

@ -8,4 +8,6 @@
(funcall f x))
(defun return (x) x)
(defun fail (x) (throw (tuple 'error x)))
(defun fail (x)
(throw (tuple 'error x)))

View file

@ -10,5 +10,8 @@
(((tuple 'just x) f)
(funcall f x)))
(defun return (x) (tuple 'just x))
(defun fail (_) 'nothing)
(defun return (x)
(tuple 'just x))
(defun fail (_)
'nothing)

View file

@ -9,9 +9,11 @@
((_) 'undefined))
(defun do-transform
((monad (cons h '())) h)
((monad (cons (list f '<- m) t)) (list '>>= monad
((monad (cons h '()))
h)
((monad (cons (list f '<- m) t))
(list '>>= monad
m
(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))))

View file

@ -9,27 +9,28 @@
;; Report exported function arities as (arity - 1) to account for
;; the extra argument supplied to tuple modules
(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
;; module_info is added by the compiler and therefore remains as-is
(((tuple 'module_info arity)) (tuple 'module_info arity))
(((tuple fun arity)) (tuple fun (- arity 1)))))
(info-dict (: dict from_list info-plist))
(new-dict (: dict store 'exports (: lists map fix-arity exports) info-dict))
(new-plist (: dict to_list new-dict)))
(info-dict (dict:from_list info-plist))
(new-dict (dict:store 'exports (lists:map fix-arity exports) info-dict))
(new-plist (dict:to_list new-dict)))
new-plist))))
(funcall fix-info (module-info module))))
((module) (call module 'module_info)))
((module)
(call module 'module_info)))
(defun module-info (module key)
(: proplists get_value key (module-info module)))
(proplists:get_value key (module-info module)))
(defun implements? (behaviour module)
(let* ((exports (module-info module 'exports))
(exported? (lambda (definition) (: lists member definition exports))))
(: lists all exported?
(exported? (lambda (definition) (lists:member definition exports))))
(lists:all exported?
(call behaviour 'behaviour_info 'callbacks))))
(defun exports? (definition module)
(: lists member definition
(lists:member definition
(module-info module 'exports)))