Skip to content

Commit

Permalink
🚚 Move DEFPACKAGE forms to a single file
Browse files Browse the repository at this point in the history
Problem:
- Having package definitions in multiple files make it difficult to
quickly view packages and the symbols they are exporting.

Solution:
- Move all of the package definition forms to a single file.
  • Loading branch information
sabjohnso committed Nov 29, 2024
1 parent 694ff87 commit 37aed94
Show file tree
Hide file tree
Showing 15 changed files with 711 additions and 178 deletions.
4 changes: 3 additions & 1 deletion contextual.asd
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@
:serial t
:components
((:module "src"
:serial t
:components
((:file "utility")
((:file "package")
(:file "utility")
(:file "syntax-helpers")
(:file "internal")
(:file "derivation")
Expand Down
3 changes: 0 additions & 3 deletions run-coverage
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ exit $?

(declaim (optimize (sb-cover:store-coverage-data 0)))
(asdf:oos 'asdf:load-op :contextual :force t)
(asdf:oos 'asdf:load-op :contextual/test :force t)


(declaim (optimize sb-cover:store-coverage-data))
(asdf:oos 'asdf:load-op :contextual :force t)
Expand Down
22 changes: 0 additions & 22 deletions src/bare-function.lisp
Original file line number Diff line number Diff line change
@@ -1,25 +1,3 @@
(in-package :cl-user)

(defpackage :contextual-bare-function
(:use :cl :binding-syntax-helpers :contextual :contextual-utility)
(:export #:make-bare-function-context
#:+bare-function+
#:bf-run
#:bf-fmap
#:bf-pure
#:bf-fapply
#:bf-mreturn
#:bf-flatmap
#:bf-flatten
#:bf-ask
#:bf-lookup
#:bf-local
#:let*-fun/bf
#:let-fun/bf
#:let-app/bf
#:let*-mond/bf
#:let-mon/bf))

(in-package :contextual-bare-function)

(eval-when (:load-toplevel :compile-toplevel)
Expand Down
37 changes: 15 additions & 22 deletions src/bare-state.lisp
Original file line number Diff line number Diff line change
@@ -1,19 +1,3 @@
(in-package :cl-user)


(defpackage :contextual-bare-state
(:nicknames :bs)
(:use :cl :contextual :contextual-derivation)
(:export
#:bs-run #:bs-exec #:bs-eval
#:bs-fmap
#:bs-pure #:bs-fapply #:bs-product
#:bs-mreturn #:bs-flatmap #:bs-bind #:bs-flatten
#:bs-mget #:bs-mput #:bs-select #:bs-modify
#:let*-fun/bs #:let-fun/bs
#:let-app/bs
#:progn-mon/bs #:let*-mon/bs #:let-mon/bs))

(in-package :contextual-bare-state)

(defun bs-run (s mx)
Expand Down Expand Up @@ -127,15 +111,24 @@ with the updated state."
(defun bs-select (f)
"Projects a value out of the current state by applying `F' to the
result of `BS-MGET'."

(lambda (s)
(list (funcall f s) s)))


(derive-monad-interface bs
:fmap bs-fmap
:pure bs-pure
:fapply bs-fapply
(defun bs-state (mx)
"Embed a simple state action into the monad. For the
bare state monad, this is simply the identity funcion."
mx)


(derive-state-monad-interface bs
:state bs-state
:mput bs-mput
:select bs-select
:mget bs-mget
:modify bs-modify
:fmap bs-fmap
:pure bs-pure
:fapply bs-fapply
:product bs-product
:mreturn bs-mreturn
:flatmap bs-flatmap
Expand Down
7 changes: 0 additions & 7 deletions src/bare.lisp
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
(in-package :cl-user)

(defpackage :contextual-bare
(:use :cl :contextual)
(:export #:make-bare-context))


(in-package :contextual-bare)

(defun make-bare-context ()
Expand Down
32 changes: 0 additions & 32 deletions src/contextual.lisp
Original file line number Diff line number Diff line change
@@ -1,35 +1,3 @@
(in-package :cl-user)

(defpackage :contextual
(:use :cl :binding-syntax-helpers :contextual-internal :contextual-derivation)
(:export
#:fmap
#:pure #:fapply #:product
#:mreturn #:flatmap #:flatten
#:wrap #:unwrap
#:extract #:duplicate #:extend
#:expel
#:ask #:lookup #:local

#:fmap-func
#:pure-func #:fapply-func #:product-func
#:flatmap-func #:flatten-func
#:wrap-func #:unwrap-func
#:extract-func #:duplicate-func #:extend-func
#:ask-func #:asks-func #:local-func

#:let*-fun #:let-fun #:let-app #:let*-mon #:let-mon
#:lift #:lift2 #:lift3 #:lift4 #:lift5 #:lift6 #:lift7

#:functor-operators
#:applicative-operators
#:monad-operators
#:comonad-operators
#:trivial-operators
#:monad-environment-operators

#:ctx-run))

(in-package :contextual)

(defgeneric fmap-func (context))
Expand Down
Loading

0 comments on commit 37aed94

Please sign in to comment.