Skip to content

Commit ac631f6

Browse files
AlexKnauthlexi-lambda
authored andcommitted
Applicative-apply should return an applicative (#9)
In particular, the examples for the `id` applicative and monad should return `id` instances from `apply`.
1 parent 9a3ec76 commit ac631f6

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

functional-doc/scribblings/data/functional.scrbl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ guarantee about what it is, so you should always ignore it completely.
171171

172172
Implementing the @racket[apply] method is somewhat more straightforward. It should be a function of
173173
two arguments, this first corresponding to the functor in application position and second a list of
174-
functors provided as arguments in the application.
174+
functors provided as arguments in the application. It should produce an applicative functor result.
175175

176176
Here is an example implementation of the most trivial possible applicative functor, the identity
177177
functor:
@@ -187,7 +187,7 @@ functor:
187187
[(define (pure _ x)
188188
(id x))
189189
(define (apply f xs)
190-
(base:apply (id-val f) (base:map id-val xs)))])
190+
(id (base:apply (id-val f) (base:map id-val xs))))])
191191
((id +) (pure 2) (pure 3)))
192192

193193
@subsection[#:tag "monads"]{Monads}
@@ -352,7 +352,7 @@ Here is an example implementation of the most trivial possible monad, the identi
352352
[(define (pure _ x)
353353
(id x))
354354
(define (apply f xs)
355-
(base:apply (id-val f) (base:map id-val xs)))]
355+
(id (base:apply (id-val f) (base:map id-val xs))))]
356356
#:methods gen:monad
357357
[(define (chain f x)
358358
(f (id-val x)))])

0 commit comments

Comments
 (0)