aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/library/lux/abstract/comonad/cofree.lux
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--stdlib/source/library/lux/abstract/comonad/cofree.lux28
1 files changed, 28 insertions, 0 deletions
diff --git a/stdlib/source/library/lux/abstract/comonad/cofree.lux b/stdlib/source/library/lux/abstract/comonad/cofree.lux
new file mode 100644
index 000000000..c0236f079
--- /dev/null
+++ b/stdlib/source/library/lux/abstract/comonad/cofree.lux
@@ -0,0 +1,28 @@
+(.module:
+ [library
+ [lux #*]]
+ [// (#+ CoMonad)
+ [//
+ [functor (#+ Functor)]]])
+
+(type: #export (CoFree F a)
+ {#.doc "The CoFree CoMonad."}
+ [a (F (CoFree F a))])
+
+(implementation: #export (functor dsl)
+ (All [F] (-> (Functor F) (Functor (CoFree F))))
+
+ (def: (map f [head tail])
+ [(f head) (\ dsl map (map f) tail)]))
+
+(implementation: #export (comonad dsl)
+ (All [F] (-> (Functor F) (CoMonad (CoFree F))))
+
+ (def: &functor (..functor dsl))
+
+ (def: (unwrap [head tail])
+ head)
+
+ (def: (split [head tail])
+ [[head tail]
+ (\ dsl map split tail)]))