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

EventWriterT remarks #4

Open
endgame opened this issue Aug 30, 2018 · 1 comment
Open

EventWriterT remarks #4

endgame opened this issue Aug 30, 2018 · 1 comment

Comments

@endgame
Copy link
Contributor

endgame commented Aug 30, 2018

In the section on EventWriterT, it talks about setting up a type ItemState. You can avoid writing the Semigroup and Monoid instances if you define it like:

{-# LANGUAGE GeneralizedNewtypeDeriving #-}
newtype ItemState = ItemState (Endo TodoItem, Any) deriving (Semigroup, Monoid)

(This makes it annoying to set up the lenses for the type, so maybe it's not worth it.)

Also, the docs recommend refactoring all the todo components into ... -> EventWriterT t ItemState m (), which works for everything except todoComplete (the checkbox), because you lose the information that it will only be an Event t (Bool -> Bool), which you do use within the component. This makes plumbing it through harder than it would otherwise be, because you have to runEventWriterT on the todoComplete, and then you only have an Endo TodoItem and you want an Endo Bool.

@endgame
Copy link
Contributor Author

endgame commented Jan 7, 2020

It might now be possible to get keep the nicer ItemState type and get the instances using deriving via.

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

1 participant