add cps_hint_*
[lambda.git] / topics / week7_introducing_monads.mdwn
index c778bb7..e73fb36 100644 (file)
@@ -1,4 +1,4 @@
-<!-- λ Λ ∀ ≡ α β γ ρ ω Ω ○ μ η δ ζ ξ ⋆ ★ • ∙ ● 𝟎 𝟏 𝟐 𝟘 𝟙 𝟚 𝟬 𝟭 𝟮 ¢ ⇧ -->
+<!-- λ Λ ∀ ≡ α β γ ρ ω Ω ○ μ η δ ζ ξ ⋆ ★ • ∙ ● ¢ ⇧; rest aren't on office machine 𝟎 𝟏 𝟐 𝟘 𝟙 𝟚 𝟬 𝟭 𝟮 -->
 
 
 The [[tradition in the functional programming
@@ -380,7 +380,7 @@ That can be helpful, but it only enables us to have _zero or one_ elements in th
     let rec catmap (k : α -> β list) (xs : α list) : β list =
       match xs with
       | [] -> []
-      | x' :: xs' -> List.append (k x') (catmap f xs')
+      | x' :: xs' -> List.append (k x') (catmap k xs')
 
 Now we can have as many elements in the result for a given `α` as `k` cares to return. Another way to write `catmap k xs` is as (Haskell) `concat (map k xs)` or (OCaml) `List.flatten (List.map k xs)`. And this is just the definition of `mbind` or `>>=` for the List Monad. The definition of `mcomp` or `<=<`, that we gave above, differs only in that it's the way to compose two functions `j` and `k`, that you'd want to `catmap`, rather than the way to `catmap` one of those functions over a value that's already a list.