User loginNavigation 
returntype polymorphism of monads done right in a dynamic languageWhile monads can be encoded in dynamicallytyped language, the usual encodings are usually uglier than monads in typeclassbased language because type inference is not there to help determine which monad instance we're talking about. Some usecases of type inference can be replaced by dynamic type dispatch, but not the socalled "return type polymorphism" where it is the type expected by the context that matters, not the type carried by values. Monads are just one instance where returntype polymorphism matters (in the form of "return : forall a, a > m a"), but this is a general problem with other structures (typically structures with a default element such as monoids/groups). Intuitively it seems that this problem would be solveable by keeping, in the dynamic type representation, a "not known yet" marker, and using the free monad operations in this case. But there is a gap from intuition from usable code, and Tony GarnockJones just wrote a very nice blog post exposing this technique in Racket: Monads in DynamicallyTyped Languages
By gasche at 20150126 10:14  LtU Forum  previous forum topic  next forum topic  other blogs  3591 reads

Browse archivesActive forum topics 
Recent comments
1 hour 26 min ago
3 hours 25 min ago
9 hours 20 min ago
1 day 2 hours ago
1 day 11 hours ago
1 day 21 hours ago
1 day 23 hours ago
1 day 23 hours ago
2 days 20 min ago
2 days 38 min ago