Referencing Capture Data in Custome Combinator

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Referencing Capture Data in Custome Combinator

Luke Cycon
Hey all!

First off, what an amazing library! Thanks for all your terrific work.

I've been picking around the codebase trying to discover a way to accomplish this, but have yet been unsuccessful.

Is it possible to implement something of these sorts: http://lpaste.net/152284

Obviously highly idealized, but is anything of those sorts possible? The idea being that, if the function returns (Just err), processing of the current request is aborted with that error. If Nothing, processing continues down the chain.

Sorry if this is painfully obvious. I have a small feeling I may be drastically overthinking this problem ;)

Thanks,
Luke

--
Reply | Threaded
Open this post in threaded view
|

Re: Referencing Capture Data in Custome Combinator

Julian Arni-2
Do you mean something like this? http://lpaste.net/152603

It's possible to write a class or a generic function that uses the right number of `:<|> left err400` if that gets annoying. Something like this: http://lpaste.net/152606

Not sure if that's entirely correct, but then the 'otherwise' case can just be 'mkError err400', no matter what the API looks like.



On Sat, Feb 13, 2016 at 1:01 AM, Luke Cycon <[hidden email]> wrote:
Hey all!

First off, what an amazing library! Thanks for all your terrific work.

I've been picking around the codebase trying to discover a way to accomplish this, but have yet been unsuccessful.

Is it possible to implement something of these sorts: http://lpaste.net/152284

Obviously highly idealized, but is anything of those sorts possible? The idea being that, if the function returns (Just err), processing of the current request is aborted with that error. If Nothing, processing continues down the chain.

Sorry if this is painfully obvious. I have a small feeling I may be drastically overthinking this problem ;)

Thanks,
Luke

--

--
Reply | Threaded
Open this post in threaded view
|

Re: Referencing Capture Data in Custome Combinator

Julian Arni-2
(A :>/-> instance is needed in order for that to be fully general:

instance MkError b => MkError (a -> b) where
  mkError = const mkError

)

On Tue, Feb 16, 2016 at 10:56 PM, Julian Arni <[hidden email]> wrote:
Do you mean something like this? http://lpaste.net/152603

It's possible to write a class or a generic function that uses the right number of `:<|> left err400` if that gets annoying. Something like this: http://lpaste.net/152606

Not sure if that's entirely correct, but then the 'otherwise' case can just be 'mkError err400', no matter what the API looks like.



On Sat, Feb 13, 2016 at 1:01 AM, Luke Cycon <[hidden email]> wrote:
Hey all!

First off, what an amazing library! Thanks for all your terrific work.

I've been picking around the codebase trying to discover a way to accomplish this, but have yet been unsuccessful.

Is it possible to implement something of these sorts: http://lpaste.net/152284

Obviously highly idealized, but is anything of those sorts possible? The idea being that, if the function returns (Just err), processing of the current request is aborted with that error. If Nothing, processing continues down the chain.

Sorry if this is painfully obvious. I have a small feeling I may be drastically overthinking this problem ;)

Thanks,
Luke

--


--
Reply | Threaded
Open this post in threaded view
|

Re: Referencing Capture Data in Custome Combinator

Luke Cycon
Ah. The tedium in having to write out the correct number of "left err400"s was what dissuaded me from that solution, but your MkError solution solves that rather nicely. Thanks for the push in the right direction!

L

On Wed, Feb 17, 2016 at 6:58 AM, Julian Arni <[hidden email]> wrote:
(A :>/-> instance is needed in order for that to be fully general:

instance MkError b => MkError (a -> b) where
  mkError = const mkError

)

On Tue, Feb 16, 2016 at 10:56 PM, Julian Arni <[hidden email]> wrote:
Do you mean something like this? http://lpaste.net/152603

It's possible to write a class or a generic function that uses the right number of `:<|> left err400` if that gets annoying. Something like this: http://lpaste.net/152606

Not sure if that's entirely correct, but then the 'otherwise' case can just be 'mkError err400', no matter what the API looks like.



On Sat, Feb 13, 2016 at 1:01 AM, Luke Cycon <[hidden email]> wrote:
Hey all!

First off, what an amazing library! Thanks for all your terrific work.

I've been picking around the codebase trying to discover a way to accomplish this, but have yet been unsuccessful.

Is it possible to implement something of these sorts: http://lpaste.net/152284

Obviously highly idealized, but is anything of those sorts possible? The idea being that, if the function returns (Just err), processing of the current request is aborted with that error. If Nothing, processing continues down the chain.

Sorry if this is painfully obvious. I have a small feeling I may be drastically overthinking this problem ;)

Thanks,
Luke

--



--