Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Modular implicits – a system for ad-hoc polymorphism in OCaml [pdf] (unsw.edu.au)
63 points by bshanks on Jan 2, 2016 | hide | past | favorite | 1 comment


Summary of the idea:

Add implicit arguments with some extra syntax. Whenever the argument is unambiguous, you can just not mention it, whenever it's ambiguous you add the argument to a function call. Modules provide the structs of related functions, so implicit module typed arguments are a good fit for "typeclass-like" functionality. The paper also mentions some nice extensions of importing implicits inside other modules.

If you know implicit arguments from Scala or Agda [0] or whatever other language, you get the mechanism.

If you know type classes from Haskell, you know the "goal" and the capabilities. Only this proposal requires less extension of the language, because you can disambiguate instances by supplying one by hand (basically implicits applied to "the scrap your typeclasses" approach [1]).

[0]: http://wiki.portal.chalmers.se/agda/pmwiki.php?n=Docs.Implic...

[1]: http://www.haskellforall.com/2012/05/scrap-your-type-classes...




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: