Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implicit-conversion example #156

Closed
gelisam opened this issue Aug 6, 2022 · 1 comment
Closed

implicit-conversion example #156

gelisam opened this issue Aug 6, 2022 · 1 comment
Labels
examples Ideas for cool things to implement in Klister to show off the language

Comments

@gelisam
Copy link
Owner

gelisam commented Aug 6, 2022

I want to implement an example which demonstrates that it is possible to define a #lang with a custom type system. More specifically, I want a type system which, as Conor McBride exhorts, does more than just rejecting bad programs, and in addition generates terms.

My current plan is to implement Scala's "implicit conversion" feature. That is, a function from A to B can be added to the list of implicit conversion functions currently in scope, and then if within that scope an A is used where a B is expected, the conversion function is automatically inserted. Here is some example code I am hoping to support:

#lang "implicit-conversion.kl"

(example
  (let-implicit string-length
    (+ 1 "foo")))

Which would become

#lang "implicit-conversion.kl"

(example
  (+ 1 (string->length "foo")))

Since my goal is only to demonstrate that this is possible, not to use the #lang in anger, I only plan to implement the minimum set of functionality to support the above example. In particular, I am not planning to include lambdas in the #lang.

@gelisam gelisam added the examples Ideas for cool things to implement in Klister to show off the language label Aug 6, 2022
@gelisam
Copy link
Owner Author

gelisam commented Feb 21, 2023

Implemented by #157.

@gelisam gelisam closed this as completed Feb 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
examples Ideas for cool things to implement in Klister to show off the language
Projects
None yet
Development

No branches or pull requests

1 participant