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

Idea - func factory #841

Closed
philn5d opened this Issue Mar 5, 2017 · 2 comments

Comments

Projects
None yet
3 participants
@philn5d

philn5d commented Mar 5, 2017

I'm new to elm-lang, seems great so far. I have an idea...

I was looking at svg src and it seems like there's a lot of unnecessarily repeated code as in https://github.com/elm-lang/svg/blob/master/src/Svg.elm perhaps which is more general to other packages as well. If there were a way to define the functions (since they all share the same type) using a function, all of that could go away and you'd don it like this -

map-type : Type -> f-> List( String ) -> g
map-type  t f names=
    names ... however you do a lambda ... name => make-func name t (f name)

make-func : Type -> f -> name -> g
make-func t name f =
    name : t
    name (get-args t) =
        f

Not really sure how it would work, but the idea is there.

Use like this:

map-svg-types =
    map-types (List( Attributes msg ) -> List ( Svg msg ) -> Svg msg) node

map-svg-types 
    [ "square"
    , "circle"
    .
    .
    ]

Well, I'm not sure about the syntax, but it would eliminate all the repeat function definitions. The map-types or maybe it should be make-funcs should create funcs of the type given across the list of function names.

@process-bot

This comment has been minimized.

Show comment
Hide comment
@process-bot

process-bot Mar 5, 2017

Thanks for the issue! Make sure it satisfies this checklist. My human colleagues will appreciate it!

Here is what to expect next, and if anyone wants to comment, keep these things in mind.

process-bot commented Mar 5, 2017

Thanks for the issue! Make sure it satisfies this checklist. My human colleagues will appreciate it!

Here is what to expect next, and if anyone wants to comment, keep these things in mind.

@evancz

This comment has been minimized.

Show comment
Hide comment
@evancz

evancz Mar 9, 2017

Member

You are describing a macro system. The issue tracker is for bugs, not for open-ended design questions. More info in https://github.com/process-bot/contribution-checklist/blob/master/issues.md

Member

evancz commented Mar 9, 2017

You are describing a macro system. The issue tracker is for bugs, not for open-ended design questions. More info in https://github.com/process-bot/contribution-checklist/blob/master/issues.md

@evancz evancz closed this Mar 9, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment