natefaubion / purescript-run

An extensible-effects implementation
MIT License
158 stars 14 forks source link

API updates 2 #7

Closed natefaubion closed 7 years ago

natefaubion commented 7 years ago

This is an alternative to #6. I've removed the privileged "base" effect, and done something which I think is more idiomatic. aff and eff are just their own effects like any other, and they can be interpreted together if need be.

natefaubion commented 7 years ago

@joneshf @paf31 What do y'all think of this sort of API?

natefaubion commented 7 years ago

Aaalllrighty then, what about this go around? All the functions now just take handlers from purescript-variant. This means multi-interpreters just work out. The only difference is instead of case_, you use send, which will handle the default case of a variant not matching.

let
  multi1 = send
    # on _foo runFoo
    # on _bar runBar
  multi2 = match
    { base1: ...
    , base2: ...
    }
program
  # runWithEffect multi
  # runEffect multi2
natefaubion commented 7 years ago

I'm happy to consider alternative as well. I don't love the idea of requiring send. I can pass it in automatically, at the expensive of longer, more opaque type signatures.