From 024513767f3c70926fe06d9f592821c501322d23 Mon Sep 17 00:00:00 2001 From: Mysaa Date: Thu, 14 Mar 2024 20:48:52 +0100 Subject: [PATCH] Implemnted (most) of MSeq monad --- src/MSeq.ml | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/MSeq.ml b/src/MSeq.ml index 3e7ddd0..6de976c 100644 --- a/src/MSeq.ml +++ b/src/MSeq.ml @@ -1,25 +1,24 @@ -type 'a t = MSeq_not_implemented_yet +type 'a t = 'a Seq.t let map (f : 'a -> 'b) (s : 'a t) : 'b t = - Utils.not_yet "MSeq.map" (f, s) + Seq.map f s let return (x : 'a) : 'a t = - Utils.not_yet "MSeq.return" x + Seq.return x let bind (sa : 'a t) (f : 'a -> 'b t) : 'b t = - Utils.not_yet "MSeq.bind" (sa, f) + Seq.concat_map f sa let delay (f : unit -> 'a t) : 'a t = - Utils.not_yet "MSeq.delay" f + fun () -> f () () (* f is already «delayed» form *) let sum (li : 'a t list) : 'a t = - Utils.not_yet "MSeq.sum" li + Seq.concat (List.to_seq li) -let fail : 'a t = - MSeq_not_implemented_yet +let fail : 'a t = Seq.empty let one_of (vs : 'a array) : 'a t = Utils.not_yet "MSeq.one_of" vs let run (s : 'a t) : 'a Seq.t = - Utils.not_yet "MSeq.run" s + s