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  3489 reads

Browse archivesActive forum topics 
Recent comments
19 min 16 sec ago
2 days 7 hours ago
2 days 8 hours ago
3 days 1 hour ago
6 days 19 hours ago
1 week 1 hour ago
1 week 3 hours ago
1 week 13 hours ago
1 week 2 days ago
1 week 3 days ago