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

setters and getters #208

Open
amigalemming opened this issue Oct 29, 2017 · 2 comments
Open

setters and getters #208

amigalemming opened this issue Oct 29, 2017 · 2 comments

Comments

@amigalemming
Copy link

threepenny uses this style for setting attributes:

 do canvas <- UI.canvas
        # set UI.width  canvasX
        # set UI.height canvasY
        # set style [("border", "solid black 1px"), ("background", "white")]

Wouldn't it be more natural to have an Access monad:

do canvas <- UI.canvas $ do
        set UI.width  canvasX
        set UI.height canvasY
        set style [("border", "solid black 1px"), ("background", "white")]

with

UI.canvas :: Access Element () -> UI Element
set :: ReadWriteAttr x i o -> i -> Access x ()
get :: ReadWriteAttr x i o -> Access x o

?
It seems to me much more straightforward to bundle setters and getters for re-use, this way.

@HeinrichApfelmus
Copy link
Owner

That's an interesting suggestion, but I do not quite see the advantage of using a special monad. It seems to save one keystroke per setter?

@amigalemming
Copy link
Author

amigalemming commented Oct 31, 2017 via email

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

No branches or pull requests

2 participants