aboutsummaryrefslogtreecommitdiff
path: root/source/lux/data/text.lux
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--source/lux/data/text.lux13
1 files changed, 13 insertions, 0 deletions
diff --git a/source/lux/data/text.lux b/source/lux/data/text.lux
index 744a22f2e..af2de51ff 100644
--- a/source/lux/data/text.lux
+++ b/source/lux/data/text.lux
@@ -180,3 +180,16 @@
_
(#;Left "Wrong syntax for <>")))
+
+(def #export (split-lines text)
+ (-> Text (List Text))
+ (case (: (Maybe (List Text))
+ (do Maybe/Monad
+ [idx (index-of "\n" text)
+ [head post] (split (inc idx) text)]
+ (wrap (#;Cons head (split-lines post)))))
+ #;None
+ (#;Cons text #;Nil)
+
+ (#;Some xs)
+ xs))