From 75e8244fd7914d2ac0c3622d2277b84c4bfa7ffb Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Sat, 4 Jun 2022 20:00:01 -0400 Subject: comonad/cofree => comonad/free --- stdlib/source/library/lux.lux | 15 +++++++++--- .../source/library/lux/abstract/comonad/cofree.lux | 27 ---------------------- .../source/library/lux/abstract/comonad/free.lux | 27 ++++++++++++++++++++++ stdlib/source/library/lux/control/exception.lux | 2 +- stdlib/source/library/lux/control/maybe.lux | 2 +- stdlib/source/library/lux/control/reader.lux | 2 +- stdlib/source/library/lux/control/state.lux | 2 +- stdlib/source/library/lux/control/try.lux | 2 +- stdlib/source/library/lux/control/writer.lux | 2 +- stdlib/source/library/lux/data/collection/list.lux | 2 +- stdlib/source/library/lux/meta/location.lux | 2 +- .../tool/compiler/language/lux/analysis/module.lux | 2 +- .../tool/compiler/language/lux/analysis/scope.lux | 2 +- .../tool/compiler/language/lux/phase/extension.lux | 2 +- stdlib/source/library/lux/tool/compiler/phase.lux | 2 +- stdlib/source/library/lux/type/check.lux | 2 +- stdlib/source/library/lux/type/implicit.lux | 2 +- 17 files changed, 53 insertions(+), 44 deletions(-) delete mode 100644 stdlib/source/library/lux/abstract/comonad/cofree.lux create mode 100644 stdlib/source/library/lux/abstract/comonad/free.lux (limited to 'stdlib/source/library') diff --git a/stdlib/source/library/lux.lux b/stdlib/source/library/lux.lux index cdcb304a0..1c550ec22 100644 --- a/stdlib/source/library/lux.lux +++ b/stdlib/source/library/lux.lux @@ -4264,11 +4264,20 @@ _ (failure (..wrong_syntax_error (symbol ..refer))))) +(macro: .public (with tokens) + (case (..parsed (..andP ..anyP ..anyP) + tokens) + {.#Some [implementation expression]} + (meta#in (list (` (..let [(..open (~ (text$ (alias_stand_in 0)))) (~ implementation)] + (~ expression))))) + + {.#None} + (failure (..wrong_syntax_error (symbol ..with))))) + (macro: .public (at tokens) (case tokens - (pattern (list struct [_ {#Symbol member}])) - (meta#in (list (` (..let [(..open (~ (text$ (alias_stand_in 0)))) (~ struct)] - (~ (symbol$ member)))))) + (pattern (list implementation [_ {#Symbol member}])) + (meta#in (list (` (..with (~ implementation) (~ (symbol$ member)))))) (pattern (partial_list struct member args)) (meta#in (list (` ((..at (~ struct) (~ member)) (~+ args))))) diff --git a/stdlib/source/library/lux/abstract/comonad/cofree.lux b/stdlib/source/library/lux/abstract/comonad/cofree.lux deleted file mode 100644 index 2b4ec2b4e..000000000 --- a/stdlib/source/library/lux/abstract/comonad/cofree.lux +++ /dev/null @@ -1,27 +0,0 @@ -(.using - [library - [lux (.except)]] - [// (.only CoMonad) - [// - [functor (.only Functor)]]]) - -(type: .public (CoFree F a) - [a (F (CoFree F a))]) - -(implementation: .public (functor dsl) - (All (_ F) (-> (Functor F) (Functor (CoFree F)))) - - (def: (each f [head tail]) - [(f head) (at dsl each (each f) tail)])) - -(implementation: .public (comonad dsl) - (All (_ F) (-> (Functor F) (CoMonad (CoFree F)))) - - (def: functor (..functor dsl)) - - (def: (out [head tail]) - head) - - (def: (disjoint [head tail]) - [[head tail] - (at dsl each disjoint tail)])) diff --git a/stdlib/source/library/lux/abstract/comonad/free.lux b/stdlib/source/library/lux/abstract/comonad/free.lux new file mode 100644 index 000000000..cba43d06d --- /dev/null +++ b/stdlib/source/library/lux/abstract/comonad/free.lux @@ -0,0 +1,27 @@ +(.using + [library + [lux (.except)]] + [// (.only CoMonad) + [// + [functor (.only Functor)]]]) + +(type: .public (Free F a) + [a (F (Free F a))]) + +(implementation: .public (functor dsl) + (All (_ F) (-> (Functor F) (Functor (Free F)))) + + (def: (each f [head tail]) + [(f head) (at dsl each (each f) tail)])) + +(implementation: .public (comonad dsl) + (All (_ F) (-> (Functor F) (CoMonad (Free F)))) + + (def: functor (..functor dsl)) + + (def: (out [head tail]) + head) + + (def: (disjoint [head tail]) + [[head tail] + (at dsl each disjoint tail)])) diff --git a/stdlib/source/library/lux/control/exception.lux b/stdlib/source/library/lux/control/exception.lux index 7aed1de63..48276683c 100644 --- a/stdlib/source/library/lux/control/exception.lux +++ b/stdlib/source/library/lux/control/exception.lux @@ -1,6 +1,6 @@ (.using [library - [lux (.except except) + [lux (.except except with) ["[0]" macro] ["[0]" meta] [abstract diff --git a/stdlib/source/library/lux/control/maybe.lux b/stdlib/source/library/lux/control/maybe.lux index 72b1f30aa..dafd471d1 100644 --- a/stdlib/source/library/lux/control/maybe.lux +++ b/stdlib/source/library/lux/control/maybe.lux @@ -1,6 +1,6 @@ (.using [library - [lux (.except list) + [lux (.except list with) [abstract [monoid (.only Monoid)] [equivalence (.only Equivalence)] diff --git a/stdlib/source/library/lux/control/reader.lux b/stdlib/source/library/lux/control/reader.lux index 651ce0eb8..cd2d5b053 100644 --- a/stdlib/source/library/lux/control/reader.lux +++ b/stdlib/source/library/lux/control/reader.lux @@ -1,6 +1,6 @@ (.using [library - [lux (.except local) + [lux (.except local with) ["@" target] [abstract [apply (.only Apply)] diff --git a/stdlib/source/library/lux/control/state.lux b/stdlib/source/library/lux/control/state.lux index b5a87549d..798e42b16 100644 --- a/stdlib/source/library/lux/control/state.lux +++ b/stdlib/source/library/lux/control/state.lux @@ -1,6 +1,6 @@ (.using [library - [lux (.except local) + [lux (.except local with) [abstract [functor (.only Functor)] [apply (.only Apply)] diff --git a/stdlib/source/library/lux/control/try.lux b/stdlib/source/library/lux/control/try.lux index dd43a0ea1..897ae0adf 100644 --- a/stdlib/source/library/lux/control/try.lux +++ b/stdlib/source/library/lux/control/try.lux @@ -1,6 +1,6 @@ (.using [library - [lux (.except) + [lux (.except with) ["@" target] [abstract [apply (.only Apply)] diff --git a/stdlib/source/library/lux/control/writer.lux b/stdlib/source/library/lux/control/writer.lux index 40540eb04..e08e494d1 100644 --- a/stdlib/source/library/lux/control/writer.lux +++ b/stdlib/source/library/lux/control/writer.lux @@ -1,6 +1,6 @@ (.using [library - [lux (.except) + [lux (.except with) ["@" target] [abstract [monoid (.only Monoid)] diff --git a/stdlib/source/library/lux/data/collection/list.lux b/stdlib/source/library/lux/data/collection/list.lux index 903d5ae3f..ba1902276 100644 --- a/stdlib/source/library/lux/data/collection/list.lux +++ b/stdlib/source/library/lux/data/collection/list.lux @@ -1,6 +1,6 @@ (.using [library - [lux (.except revised all only) + [lux (.except revised all only with) ["@" target] [abstract [monoid (.only Monoid)] diff --git a/stdlib/source/library/lux/meta/location.lux b/stdlib/source/library/lux/meta/location.lux index 640dcee6a..c66147ba8 100644 --- a/stdlib/source/library/lux/meta/location.lux +++ b/stdlib/source/library/lux/meta/location.lux @@ -1,6 +1,6 @@ (.using [library - [lux (.except) + [lux (.except with) [abstract [equivalence (.only Equivalence)]]]]) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/analysis/module.lux b/stdlib/source/library/lux/tool/compiler/language/lux/analysis/module.lux index 9aabc7d10..1a897fb6c 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/analysis/module.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/analysis/module.lux @@ -1,6 +1,6 @@ (.using [library - [lux (.except Label) + [lux (.except Label with) [abstract ["[0]" monad (.only do)]] [control diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/analysis/scope.lux b/stdlib/source/library/lux/tool/compiler/language/lux/analysis/scope.lux index bf221d35b..2fa60d94f 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/analysis/scope.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/analysis/scope.lux @@ -1,6 +1,6 @@ (.using [library - [lux (.except local) + [lux (.except local with) [abstract [monad (.only do)]] [control diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension.lux index 493776886..e2fe1fd05 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension.lux @@ -1,6 +1,6 @@ (.using [library - [lux (.except) + [lux (.except with) [abstract [equivalence (.only Equivalence)] [hash (.only Hash)] diff --git a/stdlib/source/library/lux/tool/compiler/phase.lux b/stdlib/source/library/lux/tool/compiler/phase.lux index e3cf241ba..480ad7380 100644 --- a/stdlib/source/library/lux/tool/compiler/phase.lux +++ b/stdlib/source/library/lux/tool/compiler/phase.lux @@ -1,6 +1,6 @@ (.using [library - [lux (.except except) + [lux (.except except with) [abstract [functor (.only Functor)] [monad (.only Monad do)]] diff --git a/stdlib/source/library/lux/type/check.lux b/stdlib/source/library/lux/type/check.lux index 497e0e6cc..4e9a81e48 100644 --- a/stdlib/source/library/lux/type/check.lux +++ b/stdlib/source/library/lux/type/check.lux @@ -1,6 +1,6 @@ (.using [library - [lux (.except try except) + [lux (.except try except with) ["@" target] [abstract [functor (.only Functor)] diff --git a/stdlib/source/library/lux/type/implicit.lux b/stdlib/source/library/lux/type/implicit.lux index fbe04737a..95e9a53dc 100644 --- a/stdlib/source/library/lux/type/implicit.lux +++ b/stdlib/source/library/lux/type/implicit.lux @@ -1,6 +1,6 @@ (.using [library - [lux (.except) + [lux (.except with) [abstract ["[0]" monad (.only do)] ["[0]" equivalence]] -- cgit v1.2.3