Skip to content

Which effect design should I use for my real world tiny Http/Spotify example? #154

Discussion options

You must be logged in to vote

Let's assume a program which should add all search results to the favorites:

searchTrackProgram :: (Http :> es, Error SpotifyError :> es, Spotify :> es) => String -> Eff es [Track]
addToFavorites :: (Http :> es, Error FavoriteError :> es, Favorite :> es) => Track -> Eff es ()

program :: ( Http :> es
           , Error SpotifyError :> es
           , Error FavoriteError :> es
           , Spotify :> es
           , Favorite :> es
           ) => String -> Eff es ()
program query = do
  tracks <- searchTrack query
  forM_ tracks addToFavorites

Here when it comes to testing, our test should be overwhelmed by handling effects i.e. Error and Http which by any means doesn't express our intenti…

Replies: 3 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@jhgarner
Comment options

Comment options

You must be logged in to vote
1 reply
@ParetoOptimalDev
Comment options

Answer selected by ParetoOptimalDev
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants