mirror of
https://github.com/correl/calrissian.git
synced 2024-11-23 19:19:57 +00:00
Merge branch 'formatting' of github.com:lfex/calrissian into formatting
This commit is contained in:
commit
ec3c5426ce
17 changed files with 157 additions and 151 deletions
2
Makefile
2
Makefile
|
@ -1 +1,3 @@
|
||||||
|
PROJECT = calrissian
|
||||||
|
|
||||||
include resources/make/common.mk
|
include resources/make/common.mk
|
||||||
|
|
|
@ -3,13 +3,13 @@
|
||||||
;; Provide the state monad in terms of the state transformer
|
;; Provide the state monad in terms of the state transformer
|
||||||
(''state `(transformer 'state 'identity))
|
(''state `(transformer 'state 'identity))
|
||||||
(_
|
(_
|
||||||
`(list_to_atom (lists:flatten (list "calrissian-"
|
`(list_to_atom (lists:flatten `("calrissian-"
|
||||||
(atom_to_list ,name)
|
,(atom_to_list ,name)
|
||||||
"-monad"))))))
|
"-monad"))))))
|
||||||
|
|
||||||
(defmacro transformer (name inner-monad)
|
(defmacro transformer (name inner-monad)
|
||||||
`(tuple (list_to_atom (lists:flatten (list "calrissian-"
|
`(tuple (list_to_atom (lists:flatten `("calrissian-"
|
||||||
(atom_to_list ,name)
|
,(atom_to_list ,name)
|
||||||
"-transformer")))
|
"-transformer")))
|
||||||
(monad ,inner-monad)))
|
(monad ,inner-monad)))
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@
|
||||||
`(call ,monad 'fail ,expr))
|
`(call ,monad 'fail ,expr))
|
||||||
|
|
||||||
(defmacro sequence (monad list)
|
(defmacro sequence (monad list)
|
||||||
`(: lists foldr
|
`(lists:foldr
|
||||||
(lambda (m acc) (mcons ,monad m acc))
|
(lambda (m acc) (mcons ,monad m acc))
|
||||||
(return ,monad [])
|
(return ,monad [])
|
||||||
,list))
|
,list))
|
||||||
|
|
11
lfe.config
Normal file
11
lfe.config
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
#(project
|
||||||
|
(#(deps (#("lfex/lcfg" "master")))
|
||||||
|
#(meta (
|
||||||
|
#(name logjam)
|
||||||
|
#(description "Monads for LFE")
|
||||||
|
#(version "0.1.0")
|
||||||
|
#(keywords ("LFE" "Lisp" "Library" "Monads"))
|
||||||
|
#(maintainers (
|
||||||
|
(#(name "Correl Roush") #(email "correl@gmail.com"))))
|
||||||
|
#(repos (
|
||||||
|
#(github "correl/calrissian")))))))
|
|
@ -1,7 +0,0 @@
|
||||||
Expm.Package.new(
|
|
||||||
name: "calrissian",
|
|
||||||
description: "Monads for LFE",
|
|
||||||
version: "0.1.0",
|
|
||||||
keywords: ["LFE", "Lisp", "Library", "Monads"],
|
|
||||||
maintainers: [[name: "Correl Roush", email: "correl@gmail.com"]],
|
|
||||||
repositories: [[github: "correl/calrissian"]])
|
|
14
rebar.config
14
rebar.config
|
@ -1,16 +1,12 @@
|
||||||
{erl_opts, [debug_info, {src_dirs, ["test/unit",
|
{erl_opts, [debug_info, {src_dirs, ["test"]}]}.
|
||||||
"test/integration",
|
|
||||||
"test/system"]}]}.
|
|
||||||
{lfe_first_files, []}.
|
{lfe_first_files, []}.
|
||||||
{deps_dir, ["deps"]}.
|
{deps_dir, ["deps"]}.
|
||||||
{eunit_compile_opts, [
|
{eunit_compile_opts, [
|
||||||
{src_dirs, ["test/unit",
|
{src_dirs, ["test"]}
|
||||||
"test/integration",
|
|
||||||
"test/system",
|
|
||||||
"src"]}
|
|
||||||
]}.
|
]}.
|
||||||
{deps, [
|
{deps, [
|
||||||
{lfe, ".*", {git, "git://github.com/rvirding/lfe.git", "develop"}},
|
{lfe, ".*", {git, "git://github.com/rvirding/lfe.git", "develop"}},
|
||||||
{'lfe-utils', ".*", {git, "https://github.com/lfe/lfe-utils.git", "master"}},
|
{lutil, ".*", {git, "https://github.com/lfex/lutil.git", "master"}},
|
||||||
{lfeunit, ".*", {git, "git://github.com/lfe/lfeunit.git", "master"}}
|
{ltest, ".*", {git, "git://github.com/lfex/ltest.git", "master"}},
|
||||||
|
{lcfg, ".*", {git, "git://github.com/lfex/lcfg.git", "master"}}
|
||||||
]}.
|
]}.
|
||||||
|
|
|
@ -1,21 +1,22 @@
|
||||||
PROJECT = calrissian
|
ifeq ($(shell which erl),)
|
||||||
|
$(error Can't find Erlang executable 'erl')
|
||||||
|
exit 1
|
||||||
|
endif
|
||||||
|
|
||||||
LIB = $(PROJECT)
|
LIB = $(PROJECT)
|
||||||
DEPS = ./deps
|
DEPS = ./deps
|
||||||
BIN_DIR = ./bin
|
BIN_DIR = ./bin
|
||||||
EXPM = $(BIN_DIR)/expm
|
|
||||||
|
|
||||||
SOURCE_DIR = ./src
|
SOURCE_DIR = ./src
|
||||||
OUT_DIR = ./ebin
|
OUT_DIR = ./ebin
|
||||||
TEST_DIR = ./test
|
TEST_DIR = ./test
|
||||||
TEST_OUT_DIR = ./.eunit
|
TEST_OUT_DIR = ./.eunit
|
||||||
SCRIPT_PATH=$(DEPS)/lfe/bin:.:./bin:"$(PATH)":/usr/local/bin
|
SCRIPT_PATH=$(DEPS)/lfe/bin:.:./bin:"$(PATH)":/usr/local/bin
|
||||||
ERL_LIBS=$(shell pwd):$(shell $(LFETOOL) info erllibs)
|
ifeq ($(shell which lfetool),)
|
||||||
EMPTY =
|
|
||||||
ifeq ($(shell which lfetool),$EMPTY)
|
|
||||||
LFETOOL=$(BIN_DIR)/lfetool
|
LFETOOL=$(BIN_DIR)/lfetool
|
||||||
else
|
else
|
||||||
LFETOOL=lfetool
|
LFETOOL=lfetool
|
||||||
endif
|
endif
|
||||||
|
ERL_LIBS=.:..:$(shell pwd):$(shell $(LFETOOL) info erllibs)
|
||||||
OS := $(shell uname -s)
|
OS := $(shell uname -s)
|
||||||
ifeq ($(OS),Linux)
|
ifeq ($(OS),Linux)
|
||||||
HOST=$(HOSTNAME)
|
HOST=$(HOSTNAME)
|
||||||
|
@ -27,76 +28,92 @@ endif
|
||||||
$(BIN_DIR):
|
$(BIN_DIR):
|
||||||
mkdir -p $(BIN_DIR)
|
mkdir -p $(BIN_DIR)
|
||||||
|
|
||||||
$(LFETOOL): $(BIN_DIR)
|
$(BIN_DIR)/lfetool: $(BIN_DIR)
|
||||||
@[ -f $(LFETOOL) ] || \
|
@make get-lfetool
|
||||||
curl -L -o ./lfetool https://raw.github.com/lfe/lfetool/master/lfetool && \
|
|
||||||
|
get-lfetool: $(BIN_DIR)
|
||||||
|
curl -L -o ./lfetool https://raw.github.com/lfe/lfetool/dev-v1/lfetool && \
|
||||||
chmod 755 ./lfetool && \
|
chmod 755 ./lfetool && \
|
||||||
mv ./lfetool $(BIN_DIR)
|
mv ./lfetool $(BIN_DIR)
|
||||||
|
|
||||||
get-version:
|
get-version:
|
||||||
@PATH=$(SCRIPT_PATH) lfetool info version
|
@PATH=$(SCRIPT_PATH) $(LFETOOL) info version
|
||||||
|
@echo "Erlang/OTP, LFE, & library versions:"
|
||||||
$(EXPM): $(BIN_DIR)
|
@ERL_LIBS=$(ERL_LIBS) PATH=$(SCRIPT_PATH) erl \
|
||||||
@[ -f $(EXPM) ] || \
|
-eval "lfe_io:format(\"~p~n\",['$(PROJECT)-util':'get-versions'()])." \
|
||||||
PATH=$(SCRIPT_PATH) lfetool install expm $(BIN_DIR)
|
-noshell -s erlang halt
|
||||||
|
|
||||||
get-deps:
|
get-deps:
|
||||||
@echo "Getting dependencies ..."
|
@echo "Getting dependencies ..."
|
||||||
@which rebar.cmd >/dev/null 2>&1 && rebar.cmd get-deps || rebar get-deps
|
@PATH=$(SCRIPT_PATH) ERL_LIBS=$(ERL_LIBS) $(LFETOOL) download deps
|
||||||
@PATH=$(SCRIPT_PATH) lfetool update deps
|
|
||||||
|
|
||||||
clean-ebin:
|
clean-ebin:
|
||||||
@echo "Cleaning ebin dir ..."
|
@echo "Cleaning ebin dir ..."
|
||||||
@rm -f $(OUT_DIR)/*.beam
|
@rm -f $(OUT_DIR)/*.beam
|
||||||
|
|
||||||
clean-eunit:
|
clean-eunit:
|
||||||
@PATH=$(SCRIPT_PATH) lfetool tests clean
|
-@PATH=$(SCRIPT_PATH) $(LFETOOL) tests clean
|
||||||
|
|
||||||
compile: get-deps clean-ebin
|
compile: get-deps clean-ebin
|
||||||
@echo "Compiling project code and dependencies ..."
|
@echo "Compiling project code and dependencies ..."
|
||||||
@which rebar.cmd >/dev/null 2>&1 && rebar.cmd compile || rebar compile
|
@which rebar.cmd >/dev/null 2>&1 && \
|
||||||
|
PATH=$(SCRIPT_PATH) ERL_LIBS=$(ERL_LIBS) rebar.cmd compile || \
|
||||||
|
PATH=$(SCRIPT_PATH) ERL_LIBS=$(ERL_LIBS) rebar compile
|
||||||
|
|
||||||
compile-no-deps: clean-ebin
|
compile-no-deps: clean-ebin
|
||||||
@echo "Compiling only project code ..."
|
@echo "Compiling only project code ..."
|
||||||
@which rebar.cmd >/dev/null 2>&1 && rebar.cmd compile skip_deps=true || rebar compile skip_deps=true
|
@which rebar.cmd >/dev/null 2>&1 && \
|
||||||
|
PATH=$(SCRIPT_PATH) ERL_LIBS=$(ERL_LIBS) \
|
||||||
|
rebar.cmd compile skip_deps=true || \
|
||||||
|
PATH=$(SCRIPT_PATH) ERL_LIBS=$(ERL_LIBS) rebar compile skip_deps=true
|
||||||
|
|
||||||
compile-tests:
|
compile-tests: clean-eunit
|
||||||
@PATH=$(SCRIPT_PATH) lfetool tests build
|
@PATH=$(SCRIPT_PATH) ERL_LIBS=$(ERL_LIBS) $(LFETOOL) tests build
|
||||||
|
|
||||||
|
repl: compile
|
||||||
|
@which clear >/dev/null 2>&1 && clear || printf "\033c"
|
||||||
|
@echo "Starting an LFE REPL ..."
|
||||||
|
@PATH=$(SCRIPT_PATH) ERL_LIBS=$(ERL_LIBS) $(LFETOOL) repl lfe +pc unicode
|
||||||
|
|
||||||
|
repl-no-deps: compile-no-deps
|
||||||
|
@which clear >/dev/null 2>&1 && clear || printf "\033c"
|
||||||
|
@echo "Starting an LFE REPL ..."
|
||||||
|
@PATH=$(SCRIPT_PATH) ERL_LIBS=$(ERL_LIBS) $(LFETOOL) repl lfe +pc unicode
|
||||||
|
|
||||||
shell: compile
|
shell: compile
|
||||||
@which clear >/dev/null 2>&1 && clear || printf "\033c"
|
@which clear >/dev/null 2>&1 && clear || printf "\033c"
|
||||||
@echo "Starting shell ..."
|
@echo "Starting an Erlang shell ..."
|
||||||
@PATH=$(SCRIPT_PATH) lfetool repl
|
@PATH=$(SCRIPT_PATH) ERL_LIBS=$(ERL_LIBS) erl + pc unicode
|
||||||
|
|
||||||
shell-no-deps: compile-no-deps
|
shell-no-deps: compile-no-deps
|
||||||
@which clear >/dev/null 2>&1 && clear || printf "\033c"
|
@which clear >/dev/null 2>&1 && clear || printf "\033c"
|
||||||
@echo "Starting shell ..."
|
@echo "Starting an Erlang shell ..."
|
||||||
@PATH=$(SCRIPT_PATH) lfetool repl
|
@PATH=$(SCRIPT_PATH) ERL_LIBS=$(ERL_LIBS) erl + pc unicode
|
||||||
|
|
||||||
clean: clean-ebin clean-eunit
|
clean: clean-ebin clean-eunit
|
||||||
@which rebar.cmd >/dev/null 2>&1 && rebar.cmd clean || rebar clean
|
@which rebar.cmd >/dev/null 2>&1 && rebar.cmd clean || rebar clean
|
||||||
|
|
||||||
check-unit-only:
|
check-unit-only:
|
||||||
@PATH=$(SCRIPT_PATH) lfetool tests unit
|
@PATH=$(SCRIPT_PATH) ERL_LIBS=$(ERL_LIBS) $(LFETOOL) tests unit
|
||||||
|
|
||||||
check-integration-only:
|
check-integration-only:
|
||||||
@PATH=$(SCRIPT_PATH) lfetool tests integration
|
@PATH=$(SCRIPT_PATH) ERL_LIBS=$(ERL_LIBS) $(LFETOOL) tests integration
|
||||||
|
|
||||||
check-system-only:
|
check-system-only:
|
||||||
@PATH=$(SCRIPT_PATH) lfetool tests system
|
@PATH=$(SCRIPT_PATH) ERL_LIBS=$(ERL_LIBS) $(LFETOOL) tests system
|
||||||
|
|
||||||
check-unit-with-deps: get-deps compile compile-tests check-unit-only
|
check-unit-with-deps: get-deps compile compile-tests check-unit-only
|
||||||
check-unit: compile-no-deps check-unit-only
|
check-unit: clean-eunit compile-no-deps check-unit-only
|
||||||
check-integration: compile check-integration-only
|
check-integration: clean-eunit compile check-integration-only
|
||||||
check-system: compile check-system-only
|
check-system: clean-eunit compile check-system-only
|
||||||
check-all-with-deps: compile check-unit-only check-integration-only \
|
check-all-with-deps: clean-eunit compile check-unit-only \
|
||||||
check-system-only
|
check-integration-only check-system-only clean-eunit
|
||||||
check-all: get-deps compile-no-deps
|
check-all: get-deps clean-eunit compile-no-deps
|
||||||
@PATH=$(SCRIPT_PATH) lfetool tests all
|
@PATH=$(SCRIPT_PATH) ERL_LIBS=$(ERL_LIBS) $(LFETOOL) tests all
|
||||||
|
|
||||||
check: check-unit-with-deps
|
check: check-unit-with-deps
|
||||||
|
|
||||||
check-travis: $(LFETOOL) check
|
check-travis: $(BIN_DIR)/lfetool check
|
||||||
|
|
||||||
push-all:
|
push-all:
|
||||||
@echo "Pusing code to github ..."
|
@echo "Pusing code to github ..."
|
||||||
|
@ -106,16 +123,6 @@ push-all:
|
||||||
git push upstream --tags
|
git push upstream --tags
|
||||||
|
|
||||||
install: compile
|
install: compile
|
||||||
@echo "Installing calrissian ..."
|
@echo "Installing lumberjack ..."
|
||||||
@PATH=$(SCRIPT_PATH) lfetool install lfe
|
@PATH=$(SCRIPT_PATH) lfetool install lfe
|
||||||
|
|
||||||
upload: $(EXPM) get-version
|
|
||||||
@echo "Preparing to upload calrissian ..."
|
|
||||||
@echo
|
|
||||||
@echo "Package file:"
|
|
||||||
@echo
|
|
||||||
@cat package.exs
|
|
||||||
@echo
|
|
||||||
@echo "Continue with upload? "
|
|
||||||
@read
|
|
||||||
$(EXPM) publish
|
|
||||||
|
|
|
@ -5,9 +5,9 @@
|
||||||
(fail 1)))
|
(fail 1)))
|
||||||
|
|
||||||
(defun >>=
|
(defun >>=
|
||||||
(((tuple 'error reason) f)
|
((`#(error ,reason) f)
|
||||||
(tuple 'error reason))
|
`#(error ,reason))
|
||||||
(((tuple 'ok value) f)
|
((`#(ok ,value) f)
|
||||||
(funcall f value))
|
(funcall f value))
|
||||||
(('ok f)
|
(('ok f)
|
||||||
(funcall f 'ok)))
|
(funcall f 'ok)))
|
||||||
|
@ -16,7 +16,7 @@
|
||||||
(('ok)
|
(('ok)
|
||||||
'ok)
|
'ok)
|
||||||
((x)
|
((x)
|
||||||
(tuple 'ok x)))
|
`#(ok ,x)))
|
||||||
|
|
||||||
(defun fail (reason)
|
(defun fail (reason)
|
||||||
(tuple 'error reason))
|
`#(error ,reason))
|
||||||
|
|
|
@ -10,4 +10,4 @@
|
||||||
(defun return (x) x)
|
(defun return (x) x)
|
||||||
|
|
||||||
(defun fail (x)
|
(defun fail (x)
|
||||||
(throw (tuple 'error x)))
|
(throw `#(error ,x)))
|
||||||
|
|
|
@ -7,11 +7,11 @@
|
||||||
(defun >>=
|
(defun >>=
|
||||||
(('nothing f)
|
(('nothing f)
|
||||||
'nothing)
|
'nothing)
|
||||||
(((tuple 'just x) f)
|
((`#(just ,x) f)
|
||||||
(funcall f x)))
|
(funcall f x)))
|
||||||
|
|
||||||
(defun return (x)
|
(defun return (x)
|
||||||
(tuple 'just x))
|
`#(just ,x))
|
||||||
|
|
||||||
(defun fail (_)
|
(defun fail (_)
|
||||||
'nothing)
|
'nothing)
|
||||||
|
|
|
@ -3,17 +3,17 @@
|
||||||
(do-transform 2)))
|
(do-transform 2)))
|
||||||
|
|
||||||
(defun behaviour_info
|
(defun behaviour_info
|
||||||
(('callbacks) (list #(>>= 2)
|
(('callbacks) '(#(>>= 2)
|
||||||
#(return 1)
|
#(return 1)
|
||||||
#(fail 1)))
|
#(fail 1)))
|
||||||
((_) 'undefined))
|
((_) 'undefined))
|
||||||
|
|
||||||
(defun do-transform
|
(defun do-transform
|
||||||
((monad (cons h '()))
|
((monad `(,h . ()))
|
||||||
h)
|
h)
|
||||||
((monad (cons (list f '<- m) t))
|
((monad `((,f <- ,m) . ,t))
|
||||||
(list '>>= monad
|
`(>>= ,monad
|
||||||
m
|
,m
|
||||||
(list 'lambda (list f) (do-transform monad t))))
|
(lambda (,f) ,(do-transform monad t))))
|
||||||
((monad (cons h t))
|
((monad `(,h . ,t))
|
||||||
(list '>> monad h (do-transform monad t))))
|
`(>> ,monad ,h ,(do-transform monad t))))
|
||||||
|
|
|
@ -4,57 +4,57 @@
|
||||||
(include-lib "include/monads.lfe")
|
(include-lib "include/monads.lfe")
|
||||||
|
|
||||||
(defun new (inner-monad)
|
(defun new (inner-monad)
|
||||||
(tuple 'calrissian-state-transformer inner-monad))
|
`#(calrissian-state-transformer ,inner-monad))
|
||||||
|
|
||||||
(defun return
|
(defun return
|
||||||
((x (tuple 'calrissian-state-transformer inner-monad))
|
((x `#(calrissian-state-transformer ,inner-monad))
|
||||||
(lambda (s) (call inner-monad 'return (tuple x s)))))
|
(lambda (s) (call inner-monad 'return (tuple x s)))))
|
||||||
|
|
||||||
(defun fail
|
(defun fail
|
||||||
((reason (tuple 'calrissian-state-transformer inner-monad))
|
((reason `#(calrissian-state-transformer ,inner-monad))
|
||||||
(lambda (_) (call inner-monad 'fail reason))))
|
(lambda (_) (call inner-monad 'fail reason))))
|
||||||
|
|
||||||
(defun >>=
|
(defun >>=
|
||||||
((x f (tuple 'calrissian-state-transformer inner-monad))
|
((x f `#(calrissian-state-transformer ,inner-monad))
|
||||||
(lambda (s)
|
(lambda (s)
|
||||||
(call inner-monad '>>=
|
(call inner-monad '>>=
|
||||||
(funcall x s)
|
(funcall x s)
|
||||||
(match-lambda (((tuple x1 s1)) (funcall (funcall f x1) s1)))))))
|
(match-lambda ((`#(,x1 ,s1)) (funcall (funcall f x1) s1)))))))
|
||||||
|
|
||||||
(defun get (_)
|
(defun get (_)
|
||||||
(lambda (s)
|
(lambda (s)
|
||||||
(tuple s s)))
|
`#(,s ,s)))
|
||||||
|
|
||||||
(defun put (s _)
|
(defun put (s _)
|
||||||
(lambda (_)
|
(lambda (_)
|
||||||
(tuple 'ok s)))
|
`#(ok ,s)))
|
||||||
|
|
||||||
(defun modify
|
(defun modify
|
||||||
((f (tuple 'calrissian-state-transformer inner-monad))
|
((f `#(calrissian-state-transformer ,inner-monad))
|
||||||
(lambda (s)
|
(lambda (s)
|
||||||
(tuple 'ok (call inner-monad 'return (funcall f s))))))
|
`#(ok ,(call inner-monad 'return (funcall f s))))))
|
||||||
|
|
||||||
(defun modify-and-return
|
(defun modify-and-return
|
||||||
((f (tuple 'calrissian-state-transformer inner-monad))
|
((f `#(calrissian-state-transformer ,inner-monad))
|
||||||
(lambda (s)
|
(lambda (s)
|
||||||
(let ((newstate (call inner-monad 'return (funcall f s))))
|
(let ((newstate (call inner-monad 'return (funcall f s))))
|
||||||
(tuple newstate newstate)))))
|
`#(,newstate ,newstate)))))
|
||||||
|
|
||||||
(defun eval
|
(defun eval
|
||||||
((m s (tuple 'calrissian-state-transformer inner-monad))
|
((m s `#(calrissian-state-transformer ,inner-monad))
|
||||||
(call inner-monad '>>=
|
(call inner-monad '>>=
|
||||||
(funcall m s)
|
(funcall m s)
|
||||||
(match-lambda (((tuple x s1))
|
(match-lambda ((`#(,x ,s1))
|
||||||
(call inner-monad 'return x))))))
|
(call inner-monad 'return x))))))
|
||||||
|
|
||||||
(defun exec
|
(defun exec
|
||||||
((m s (tuple 'calrissian-state-transformer inner-monad))
|
((m s `#(calrissian-state-transformer ,inner-monad))
|
||||||
(call inner-monad '>>=
|
(call inner-monad '>>=
|
||||||
(funcall m s)
|
(funcall m s)
|
||||||
(match-lambda (((tuple x s1))
|
(match-lambda ((`#(,x ,s1))
|
||||||
(call inner-monad 'return s1))))))
|
(call inner-monad 'return s1))))))
|
||||||
|
|
||||||
(defun run
|
(defun run
|
||||||
((m s (tuple 'calrissian-state-transformer inner-monad))
|
((m s `#(calrissian-state-transformer ,inner-monad))
|
||||||
(funcall m s)))
|
(funcall m s)))
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
(export (behaviour_info 1)))
|
(export (behaviour_info 1)))
|
||||||
|
|
||||||
(defun behaviour_info
|
(defun behaviour_info
|
||||||
(('callbacks) (list #(run 2)
|
(('callbacks) `(#(run 2)
|
||||||
#(get 0)
|
#(get 0)
|
||||||
#(put 1)
|
#(put 1)
|
||||||
#(modify 1)
|
#(modify 1)
|
||||||
|
|
|
@ -1,19 +1,28 @@
|
||||||
(defmodule calrissian-util
|
(defmodule calrissian-util
|
||||||
(export (module-info 1)
|
(export (get-version 0)
|
||||||
|
(get-versions 0)
|
||||||
|
(module-info 1)
|
||||||
(module-info 2)
|
(module-info 2)
|
||||||
(implements? 2)
|
(implements? 2)
|
||||||
(exports? 2)))
|
(exports? 2)))
|
||||||
|
|
||||||
|
(defun get-version ()
|
||||||
|
(lutil:get-app-version 'calrissian))
|
||||||
|
|
||||||
|
(defun get-versions ()
|
||||||
|
(++ (lutil:get-versions)
|
||||||
|
`(#(calrissian ,(get-version)))))
|
||||||
|
|
||||||
(defun module-info
|
(defun module-info
|
||||||
(((tuple module _args))
|
((`#(,module ,_args))
|
||||||
;; 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))
|
((`#(module_info ,arity)) `#(module_info ,arity))
|
||||||
(((tuple fun arity)) (tuple fun (- arity 1)))))
|
((`#(,fun ,arity)) `#(,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)))
|
||||||
|
|
|
@ -1,13 +1,10 @@
|
||||||
(defmodule unit-calrissian-error-monad-tests
|
(defmodule unit-calrissian-error-monad-tests
|
||||||
(export all)
|
(behaviour ltest-unit)
|
||||||
(import
|
(export all))
|
||||||
(from lfeunit-util
|
|
||||||
(check-failed-assert 2)
|
|
||||||
(check-wrong-assert-exception 2))))
|
|
||||||
|
|
||||||
(include-lib "deps/lfeunit/include/lfeunit-macros.lfe")
|
(include-lib "ltest/include/ltest-macros.lfe")
|
||||||
(include-lib "include/monads.lfe")
|
(include-lib "calrissian/include/monads.lfe")
|
||||||
(include-lib "include/monad-tests.lfe")
|
(include-lib "calrissian/include/monad-tests.lfe")
|
||||||
|
|
||||||
(test-monad (monad 'error))
|
(test-monad (monad 'error))
|
||||||
|
|
|
@ -1,13 +1,10 @@
|
||||||
(defmodule unit-calrissian-identity-monad-tests
|
(defmodule unit-calrissian-identity-monad-tests
|
||||||
(export all)
|
(behaviour ltest-unit)
|
||||||
(import
|
(export all))
|
||||||
(from lfeunit-util
|
|
||||||
(check-failed-assert 2)
|
|
||||||
(check-wrong-assert-exception 2))))
|
|
||||||
|
|
||||||
(include-lib "deps/lfeunit/include/lfeunit-macros.lfe")
|
(include-lib "ltest/include/ltest-macros.lfe")
|
||||||
(include-lib "include/monads.lfe")
|
(include-lib "calrissian/include/monads.lfe")
|
||||||
(include-lib "include/monad-tests.lfe")
|
(include-lib "calrissian/include/monad-tests.lfe")
|
||||||
|
|
||||||
(test-monad (monad 'identity))
|
(test-monad (monad 'identity))
|
||||||
|
|
|
@ -1,13 +1,10 @@
|
||||||
(defmodule unit-calrissian-maybe-monad-tests
|
(defmodule unit-calrissian-maybe-monad-tests
|
||||||
(export all)
|
(behaviour ltest-unit)
|
||||||
(import
|
(export all))
|
||||||
(from lfeunit-util
|
|
||||||
(check-failed-assert 2)
|
|
||||||
(check-wrong-assert-exception 2))))
|
|
||||||
|
|
||||||
(include-lib "deps/lfeunit/include/lfeunit-macros.lfe")
|
(include-lib "ltest/include/ltest-macros.lfe")
|
||||||
(include-lib "include/monads.lfe")
|
(include-lib "calrissian/include/monads.lfe")
|
||||||
(include-lib "include/monad-tests.lfe")
|
(include-lib "calrissian/include/monad-tests.lfe")
|
||||||
|
|
||||||
(test-monad (monad 'maybe))
|
(test-monad (monad 'maybe))
|
||||||
|
|
|
@ -1,13 +1,10 @@
|
||||||
(defmodule unit-calrissian-state-transformer-tests
|
(defmodule unit-calrissian-state-transformer-tests
|
||||||
(export all)
|
(behaviour ltest-unit)
|
||||||
(import
|
(export all))
|
||||||
(from lfeunit-util
|
|
||||||
(check-failed-assert 2)
|
|
||||||
(check-wrong-assert-exception 2))))
|
|
||||||
|
|
||||||
(include-lib "deps/lfeunit/include/lfeunit-macros.lfe")
|
(include-lib "ltest/include/ltest-macros.lfe")
|
||||||
(include-lib "include/monads.lfe")
|
(include-lib "calrissian/include/monads.lfe")
|
||||||
(include-lib "include/monad-tests.lfe")
|
(include-lib "calrissian/include/monad-tests.lfe")
|
||||||
|
|
||||||
(test-monad (transformer 'state 'identity))
|
(test-monad (transformer 'state 'identity))
|
||||||
|
|
Loading…
Reference in a new issue