-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Question: Combining bi-functors/nesting and with covering/stripping #55
Comments
Maybe my last code-snippet with addB :: (BareB b, ApplicativeB (b Covered)) => b Bare Identity -> b Covered Maybe -> b Bare Identity
addB x dx = bstrip $ bzipWith fromMaybeI (bcover x) dx
fromMaybeI :: Identity a -> Maybe a -> Identity a
fromMaybeI (Identity a) Nothing = Identity a
fromMaybeI _ (Just a) = Identity a For sure I can implemented this for my nested add :: Foo Bare Identity Identity -> Foo Covered Maybe Maybe -> Foo Bare Identity Identity
add (Foo x y) (Foo dx dy) = Foo (runIdentity $ fromMaybeI (Identity x) dx) (maybe y (addB y) dy) But is it possible to write something similar to |
As you say, in order to use |
Thanks for your quick reply. While it is easy to "copy" barbies-2.1.1.0:Barbies.Generics.Bare.GBare
0
(Rec
(Data.Functor.Identity.Identity
(Nested2FW
Covered
(barbies-2.1.1.0:Data.Generics.GenericN.Param
0 Data.Functor.Identity.Identity)))
(Data.Functor.Identity.Identity
(Nested2FW Covered Data.Functor.Identity.Identity)))
(Rec
(Nested2FW
Bare
(barbies-2.1.1.0:Data.Generics.GenericN.Param
0 Data.Functor.Identity.Identity))
(Nested2FW Bare Data.Functor.Identity.Identity))’ Guess the problem is that it is not obvious for GHC that Coercible a b => GBare n (Rec (Identity a) (Identity a)) (Rec b b) could match. |
If it's any consolation, I need to think again from the beginning how this works every time I work on it :) Not sure how useful it will be without the commentary, but here are some old slides that I used to explain the general idea behind As a first step, what I'd do is study a bit how the generic implementation of FunctorB and FunctorT differ, as that will probably guide you into what needs to be done for BareB / BareT? |
Thank you, a really good introduction to the subject. But I'm still getting a bit confused. At the moment I can understand it more or less for each of the paths - but somehow I need both simultaneously (in order to be able to switch between |
Hi, first thank you for this library - I really love the approach ❤️.
While I am playing around with modelling a data type that I can view both as a "whole" (
Identity
) and as "patch" (Maybe
) - so that the can add patches (Semigroup
) and apply them also to the whole object I stumbled around the following problem/question (but I'm pretty sure this is due to some misconception or limited knowledge on my side - but maybe you can point me to the right direction):How can I combine bi-functors/nesting with covering/stripping?
To illustrate my problem:
This code works fine, but my problems begin to arise if I try to model using
Wear
to get rid ofIdentity
for the "whole".And now to my problem - how to cover
Foo
?For sure, by looking at the types it is pretty obvious why this couldn't work- however I'm relatively unsure if or how this could be resolved. As far as I get I couldn't implement
BareB
forFoo
? Do "we" miss something likeBareT
?Thanks in advance for any hint how to solve this and please let me know if I was unclear or could contribute further information.
The text was updated successfully, but these errors were encountered: