Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

List applicative is wrong #94

Open
Tuplanolla opened this issue May 31, 2023 · 0 comments
Open

List applicative is wrong #94

Tuplanolla opened this issue May 31, 2023 · 0 comments

Comments

@Tuplanolla
Copy link

The applicative instance for lists does not behave the way it should.
Compare the following Racket program
with the Haskell program following it
to observe the crucial difference.

#lang algebraic/racket/base

(require algebraic/control/applicative)
(require algebraic/data/list)

(with-instance list-applicative
  (<*> (list add1 sub1) (list 42 13)))
; '(43 12)

(with-instance list-applicative
  (<*> (list add1 sub1) (list 42 13 7)))
; map: all lists must have same size
main :: IO ()
main = do
  print ([(+ 1), (subtract 1)] <*> [42, 13])
  -- [43, 14, 41, 12]
  print ([(+ 1), (subtract 1)] <*> [42, 13, 7])
  -- [43, 14, 8, 41, 12, 6]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant