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

Allow 'build' with named fields #15

Closed
neongreen opened this issue Aug 9, 2019 · 4 comments
Closed

Allow 'build' with named fields #15

neongreen opened this issue Aug 9, 2019 · 4 comments

Comments

@neongreen
Copy link

Currently build is not great to use – you can mix up the field order:

>>> :{
test :: _
test = build @User
:}
...
...  Found type wildcard _
...     standing for f [Char] -> f Int -> f Bool -> HKD User f
...

(Here you can't, but if there were two Ints, you could.)

I propose adding a version that uses the named library:

test
    :: "name"      :! f [Char]
    -> "age"       :! f Int
    -> "likesDogs" :! f Bool
    -> HKD User f
test = buildNamed @User

Then the function can be called like this:

test (#name ...) (#age ...) (#likesDogs ...)

Or in this style, which allows supplying the arguments in any order:

test
    ! #likesDogs ...
    ! #name ...
    ! #age ...
@i-am-tom
Copy link
Owner

Oh wow, nice! I like this a lot. I'll play around this weekend and see what I can do, but I'm very into it! :)

@i-am-tom
Copy link
Owner

Sorry for how long it has taken to get back to this - I got sidetracked by talk-writing 😅 I've messed around with this a little, and I really like how it turns out, so I'll try to get a PR together this week if you're willing to review? :)

@neongreen
Copy link
Author

Sure!

@i-am-tom
Copy link
Owner

I'll shut this thread and move us over to #16 - hopefully, it's not too far from what you had in mind! :)

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