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

Browse archivesActive forum topics 
Recent comments
1 day 21 hours ago
1 week 3 days ago
1 week 5 days ago
1 week 5 days ago
1 week 5 days ago
1 week 5 days ago
1 week 5 days ago
1 week 5 days ago
1 week 5 days ago
1 week 5 days ago