diff --git a/src/HasReader.hs b/src/HasReader.hs index 9e1b3ba..b6362a1 100644 --- a/src/HasReader.hs +++ b/src/HasReader.hs @@ -75,15 +75,15 @@ instance -- The constraint raises @-Wsimplifiable-class-constraints@. -- This could be avoided by instead placing @HasField'@s constraints here. -- Unfortunately, it uses non-exported symbols from @generic-lens@. - ( Generic r', Generic.HasField' field r' r, HasReader tag r' m ) - => HasReader tag r (Field field m) + ( Generic record, Generic.HasField' field record v, HasReader tag record m ) + => HasReader tag v (Field field m) where - ask_ _ = coerce @(m r) $ + ask_ _ = coerce @(m v) $ asks @tag $ view (Generic.field' @field) local_ - :: forall a. Proxy# tag -> (r -> r) -> Field field m a -> Field field m a - local_ tag = coerce @((r -> r) -> m a -> m a) $ + :: forall a. Proxy# tag -> (v -> v) -> Field field m a -> Field field m a + local_ tag = coerce @((v -> v) -> m a -> m a) $ local_ tag . over (Generic.field' @field) - reader_ :: forall a. Proxy# tag -> (r -> a) -> Field field m a + reader_ :: forall a. Proxy# tag -> (v -> a) -> Field field m a reader_ tag f = coerce @(m a) $ reader_ tag $ f . view (Generic.field' @field) diff --git a/src/HasState.hs b/src/HasState.hs index 28b6d03..4a96d8b 100644 --- a/src/HasState.hs +++ b/src/HasState.hs @@ -88,15 +88,15 @@ instance -- The constraint raises @-Wsimplifiable-class-constraints@. -- This could be avoided by instead placing @HasField'@s constraints here. -- Unfortunately, it uses non-exported symbols from @generic-lens@. - ( Generic s', Generic.HasField' field s' s, HasState tag s' m ) - => HasState tag s (Field field m) + ( Generic record, Generic.HasField' field record v, HasState tag record m ) + => HasState tag v (Field field m) where - get_ _ = coerce @(m s) $ + get_ _ = coerce @(m v) $ gets @tag $ view (Generic.field' @field) - put_ _ = coerce @(s -> m ()) $ - modify @tag . set (Generic.field' @field @s') - state_ :: forall a. Proxy# tag -> (s -> (a, s)) -> Field field m a - state_ _ = coerce @((s -> (a, s)) -> m a) $ + put_ _ = coerce @(v -> m ()) $ + modify @tag . set (Generic.field' @field @record) + state_ :: forall a. Proxy# tag -> (v -> (a, v)) -> Field field m a + state_ _ = coerce @((v -> (a, v)) -> m a) $ state @tag . Generic.field' @field @_ @_ @((,) a)