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

Maybe support inline type hint #2

Open
gyson opened this issue Apr 27, 2019 · 0 comments
Open

Maybe support inline type hint #2

gyson opened this issue Apr 27, 2019 · 0 comments
Labels

Comments

@gyson
Copy link
Owner

gyson commented Apr 27, 2019

We should already be able to do type hint with T.assert( expr :: type ). For example,

map = %{} 

# type is empty map

T.assert(map :: %{optional(String.t) => integer})

# type is updated to %{optional(String.t) => integer} now.

if we support inline type hint like expr ~> type annotation. it may be easier (syntax sugar) to do type declaration, especially in pattern match.

we can do

{first ~> integer(), second ~> String.t} = something_untyped

instead of

{first, second} = something_untyped
T.assert first :: integer
T.assert second :: String.t

^^ benefit is to avoid write first and second twice.

Implementation concern

need to do some hacky thing to make it work. not sure if it worths the cost.

@gyson gyson added the maybe label Apr 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant