Hacker News new | ask | show | jobs
by dragonwriter 4607 days ago
> You can't have monads in Scheme due to the lack of a type system.

You can have monads in almost any language. The lack of static typing means you don't have static type safety with them, but monads aren't any different than anything else in that regard.

> What you can have are instances of monads, but the point of using the concept of a monad is to abstract over it, and to have functions that work with any possible instance.

How does not having static typing prevent you from abstracting over monads? You can still write functions that work with any possible instance of a monad in languages without static typing.

1 comments

> How does not having static typing prevent you from abstracting over monads?

They were probably talking about the way Haskell can figure out which monad you're in through type inference. As an example, `return :: a -> m a` dispatches on the type of the function's return value, which doesn't map cleanly to a dynamically typed implementation. You need to be explicit about the monad you're in if you don't have the compiler helping you out.

That's true (and, heck, its true even of many static languages that support monads; that feature of Haskell is due to its better-than-most type inference, not just having static typing), but I don't see how that limits the capacity for abstraction. Certainly, you may need an additional explicit parameter in some cases rather than effectively implicitly supplying information via type inference, but that doesn't change the level of abstraction.