Conversation
|
Note that the above benchmarks are not reflective of the latest changes in this branch. The changes show below had an impact on the performance characteristics. Specifically, the update to the -instance applyFreeAp :: Apply f => Apply (FreeAp f) where
+instance applyFreeAp :: Functor f => Apply (FreeAp f) where
apply (Pure k) f = k <$> f
- apply (Ap d) (Pure k) = Ap ((#) k <$> d)
- apply (Ap d) (Ap e) = Ap (d <*> e)
+ apply (Ap d) e = runDay (\i f g -> Ap (day (\x (Tuple y a) -> i x y a) f (pure Tuple <*> g <*> e))) d
-instance applicativeFreeAp :: Applicative f => Applicative (FreeAp f) where
+instance applicativeFreeAp :: Functor f => Applicative (FreeAp f) where
pure = PurefoldFreeAp (small)retractFreeAp (small) |
|
Benchmark results (small and large) removing the usage of -instance applyFreeAp :: Functor f => Apply (FreeAp f) where
- apply (Pure k) f = k <$> f
- apply (Ap d) e = runDay (\i f g -> Ap (day (\x (Tuple y a) -> i x y a) f (pure Tuple <*> g <*> e))) d
+instance applyFreeAp :: Apply (FreeAp f) where
+ apply (Pure k) (Pure a) = Pure (k a)
+ apply (Pure k) (Ap d) = Ap (k <$> d)
+ apply (Ap d) e = runDay (\i f g -> Ap (day (#) f (pure (\y a -> (\x -> i x y a)) <*> g <*> e))) d
-instance applicativeFreeAp :: Functor f => Applicative (FreeAp f) where
+instance applicativeFreeAp :: Applicative (FreeAp f) where
pure = PurefoldFreeAp (small)retractFreeAp (small)foldFreeAp (large)retractFreeAp (large) |
|
Hmm, it's a little bit of a shame about I wonder if you could move the Do you have any other thoughts on why those might be slower? |
|
Regarding stack issue, functor instance of Day is not safe as it accumulates Therefore map of the FreeAp is not safe. apply part here The implementation is nicer then one in #9 but both are unsafe in terms of stack size. I would like to try to open PR with something like this #9 (comment) but written in PS so let's see |
|
Sounds good. I would be interested in a PR for this. Thanks! |
|
Superseded by #13 |







@paf31 I have an initial attempt at implementing in terms of
Day. It's not quite done yet and I have to get the tests working, but it is almost there. I'd definitely be interested in any thoughts you might have. Thanks!foldFreeAp
retractFreeAp