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

Reflection / runtime type introspection #507

Open
futpib opened this issue Mar 18, 2018 · 6 comments
Open

Reflection / runtime type introspection #507

futpib opened this issue Mar 18, 2018 · 6 comments

Comments

@futpib
Copy link
Contributor

futpib commented Mar 18, 2018

I think the function signature (as in S.even.toString()) should be accessible programmatically as a first-class thing (not a string), maybe behind a new option of $.create.

@davidchambers
Copy link
Member

Are you imagining something like the following?

> S.even.types.length
2

> S.even.types[0] === $.Integer
true

> S.even.types[1] === $.Boolean
true

@futpib
Copy link
Contributor Author

futpib commented Mar 18, 2018

Yes, or maybe via S.type.

@futpib
Copy link
Contributor Author

futpib commented Mar 18, 2018

Actually, I can't imagine an f.types-like API that could expose type constraints, so it must be more elaborate.

Maybe a way to get arguments that were passed to def will do?

@davidchambers
Copy link
Member

How about this?

f.name :: String
f.constraints :: StrMap (Array TypeClass)
f.types :: Array Type

@futpib
Copy link
Contributor Author

futpib commented Mar 21, 2018

Looks good.

It seems that if this gets implemented, type classes could then check method signatures (at the moment they only seem to check if methods exist). Is this desirable?

@davidchambers
Copy link
Member

I don't think type classes such as Z.Functor should depend on Sanctuary-specific properties. sanctuary-type-classes is intended to interoperate with the wider Fantasy Land ecosystem.

This issue really belongs in the sanctuary-def issue tracker. Would you mind opening a new issue there, @futpib?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants