haxl

Code reuse in Haxl - avoiding GADT constructor-per-request-type

血红的双手。 提交于 2019-12-11 02:35:59
问题 Haxl is an amazing library, but one of the major pain points I find is caused by the fact that each sort of request to the data source requires its own constructor in the Request GADT. For example, taking the example from the tutorial: data BlogRequest a where FetchPosts :: BlogRequest [PostId] FetchPostContent :: PostId -> BlogRequest PostContent Then each of these constructors are pattern matched on and processed separately in the match function of the DataSource instance. This style

Applicative instance for MaybeT m assumes Monad m

时间秒杀一切 提交于 2019-12-05 13:15:44
问题 I've been using the Haxl monad (described here: http://www.reddit.com/r/haskell/comments/1le4y5/the_haxl_project_at_facebook_slides_from_my_talk), which has the interesting feature that <*> for its Applicative instance isn't the same as ap from Control.Monad. This is a key feature that allows it to do concurrent computations without blocking. For example, if hf and ha are long computations, then let hf :: Haxl (a -> b) = ... ha :: Haxl a = ... in do f <- hf a <- ha return (f a) will do them

Concurrent data access as in Haxl and Stitch

别说谁变了你拦得住时间么 提交于 2019-12-05 00:08:33
问题 This is a follow-up to my previous question. As I understand from Haxl and Stitch they use a monad for data access. The monad is actually a tree of data access commands. The children are the commands the node depends on. The siblings are executed concurrently. The business logic creates the monad and then a separate function fetch interprets it. Now, the question: Suppose I am performing a few data access operations concurrently. I can use an applicative functor (not a monad), which is just a

Applicative instance for MaybeT m assumes Monad m

余生颓废 提交于 2019-12-04 01:56:52
I've been using the Haxl monad (described here: http://www.reddit.com/r/haskell/comments/1le4y5/the_haxl_project_at_facebook_slides_from_my_talk ), which has the interesting feature that <*> for its Applicative instance isn't the same as ap from Control.Monad. This is a key feature that allows it to do concurrent computations without blocking. For example, if hf and ha are long computations, then let hf :: Haxl (a -> b) = ... ha :: Haxl a = ... in do f <- hf a <- ha return (f a) will do them sequentially, while hf <*> ha will do them in parallel and then combine the results. I would like to be