diff options
Diffstat (limited to 'stdlib/source/library/lux/abstract/comonad/free.lux')
-rw-r--r-- | stdlib/source/library/lux/abstract/comonad/free.lux | 27 |
1 files changed, 27 insertions, 0 deletions
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)])) |