Skip to content

Commit

Permalink
Rename type variables to improve readability
Browse files Browse the repository at this point in the history
Addresses #4 (comment)
  • Loading branch information
aherrmann committed Aug 10, 2018
1 parent 9e5248e commit 6950262
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
12 changes: 6 additions & 6 deletions src/HasReader.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
14 changes: 7 additions & 7 deletions src/HasState.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down

0 comments on commit 6950262

Please sign in to comment.