From 92f2e940f4c70753c7f2ddb07cca35c820c22afe Mon Sep 17 00:00:00 2001 From: Jakub Svec Date: Sun, 19 Jan 2025 17:35:14 -0800 Subject: [PATCH 1/4] Update snippet06.ml to match Haskell snippet This code is copied and pasted from the previous content in "src/content/1.4/ocaml/snippet05.ml" to match the Haskell code to which it is associated --- src/content/1.4/code/ocaml/snippet06.ml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/content/1.4/code/ocaml/snippet06.ml b/src/content/1.4/code/ocaml/snippet06.ml index ed0f0d298..461f7320d 100644 --- a/src/content/1.4/code/ocaml/snippet06.ml +++ b/src/content/1.4/code/ocaml/snippet06.ml @@ -1,3 +1,7 @@ +let up_case : string -> string writer = + fun s -> String.uppercase s, "up_case " +;; + let to_words : string -> string list writer = fun s -> String.split s ~on:' ', "to_words " ;; From 1c9c19da0d8050c8bdfdfddfba244c1d47a498d1 Mon Sep 17 00:00:00 2001 From: Jakub Svec Date: Sun, 19 Jan 2025 17:38:18 -0800 Subject: [PATCH 2/4] Update snippet05.ml to match Haskell snippet This code is the same code found in the KleisliIdentity module in section 8.5 in order to match the Haskell code to which it is associated --- src/content/1.4/code/ocaml/snippet05.ml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/content/1.4/code/ocaml/snippet05.ml b/src/content/1.4/code/ocaml/snippet05.ml index 380e46a53..c3310c8c9 100644 --- a/src/content/1.4/code/ocaml/snippet05.ml +++ b/src/content/1.4/code/ocaml/snippet05.ml @@ -1,3 +1 @@ -let up_case : string -> string writer = - fun s -> String.uppercase s, "up_case " -;; +let return : 'a -> 'a writer = fun a -> a, "" From 04ab67b23b48c840b645666f9eae936dae18caa1 Mon Sep 17 00:00:00 2001 From: Jakub Svec Date: Sun, 19 Jan 2025 17:41:04 -0800 Subject: [PATCH 3/4] Update snippet04.ml to match Haskell snippet This is the same code found in section 8.5 in the KleisliComposition module in order to match the Haskell code to which it is associated --- src/content/1.4/code/ocaml/snippet04.ml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/content/1.4/code/ocaml/snippet04.ml b/src/content/1.4/code/ocaml/snippet04.ml index d7c311f4f..ccaab18c8 100644 --- a/src/content/1.4/code/ocaml/snippet04.ml +++ b/src/content/1.4/code/ocaml/snippet04.ml @@ -1 +1,4 @@ -let pure x = x, "" +let ( >=> ) = fun m1 m2 -> + let y, s1 = m1 x in + let z, s2 = m2 x in + z, StringLabels.concat +sep:"" [ s1; s2 ] From 27daf4a2c96b8d494c0d0305061e2d1c3850233b Mon Sep 17 00:00:00 2001 From: Jakub Svec Date: Thu, 20 Feb 2025 08:35:21 -0800 Subject: [PATCH 4/4] add reason fixes to section 1.4 --- src/content/1.4/code/ocaml/snippet04.ml | 2 +- src/content/1.4/code/reason/snippet04.re | 8 +++++++- src/content/1.4/code/reason/snippet05.re | 3 +-- src/content/1.4/code/reason/snippet06.re | 9 +++++---- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/content/1.4/code/ocaml/snippet04.ml b/src/content/1.4/code/ocaml/snippet04.ml index ccaab18c8..eb379cb0c 100644 --- a/src/content/1.4/code/ocaml/snippet04.ml +++ b/src/content/1.4/code/ocaml/snippet04.ml @@ -1,4 +1,4 @@ let ( >=> ) = fun m1 m2 -> let y, s1 = m1 x in let z, s2 = m2 x in - z, StringLabels.concat +sep:"" [ s1; s2 ] + z, StringLabels.concat ~sep:"" [ s1; s2 ] diff --git a/src/content/1.4/code/reason/snippet04.re b/src/content/1.4/code/reason/snippet04.re index e79f8aacc..00766164b 100644 --- a/src/content/1.4/code/reason/snippet04.re +++ b/src/content/1.4/code/reason/snippet04.re @@ -1 +1,7 @@ -let pure = x => (x, ""); +let (>=>) = (m1, m2) => { + let (y, s1) = m1(x); + + let (z, s2) = m2(x); + + (z, StringLabels.concat(~sep="", [s1, s2])); +}; diff --git a/src/content/1.4/code/reason/snippet05.re b/src/content/1.4/code/reason/snippet05.re index dcd0f1da2..08c04bccd 100644 --- a/src/content/1.4/code/reason/snippet05.re +++ b/src/content/1.4/code/reason/snippet05.re @@ -1,2 +1 @@ -let up_case: string => writer(string) = - s => (String.uppercase(s), "up_case "); \ No newline at end of file +let return: 'a => writer('a) = a => (a, ""); diff --git a/src/content/1.4/code/reason/snippet06.re b/src/content/1.4/code/reason/snippet06.re index 93cefe6c6..a0695f62c 100644 --- a/src/content/1.4/code/reason/snippet06.re +++ b/src/content/1.4/code/reason/snippet06.re @@ -1,4 +1,5 @@ -let to_words: string => writer(list(string)) = ( - s => (String.split(s, ~on=' '), "to_words "): - string => writer(list(string)) -); +let up_case: string => writer(string) = + s => (String.uppercase(s), "up_case "); + +let to_words: string => writer(list(string)) = + s => (String.split(s, ~on=' '), "to_words ");kkkk