How to increase the acid state?

data Foo = Foo { _bar :: Map String Integer } deriving (Eq, Ord, Read, Show, Data, Typeable) $(deriveSafeCopy 0 'base 'Foo) $(makeLenses ''Foo) 

Given the code above, I get the impression that this should be possible:

 addEntry :: String -> Update Foo () addEntry s = zoom bar $ modify $ insert s 0 

But the GHC will complain line by line:

 src/Backend.hs:39:20: No instance for (Functor (Control.Lens.Internal.Zoom.Zoomed (Update Foo) ())) 

Any ideas?

+6
source share
1 answer

Control.Lens.Internal.Zoom.Zoomed is a type family that describes what context is required during zoom . It performs some special magic, as you can see in the Control.Lens.Internal.Zoom module . Normally, the zoom user will never need to see this material while they expand their β€œtypical” monad transformer stack.

Update , being implemented only as State under covers, does not have an instance of scaling. Its implementation is not exported either because you cannot write your own, although that would be pretty trivial since Update does not use monad transformers.

 type instance Zoomed (Update x) = Focusing Identity 
+8
source

All Articles