Skip to content
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

add a way to map value at specific label #23

Open
safareli opened this issue Mar 19, 2018 · 1 comment
Open

add a way to map value at specific label #23

safareli opened this issue Mar 19, 2018 · 1 comment

Comments

@safareli
Copy link

safareli commented Mar 19, 2018

I needed something like this at one point let me know if you like this and will open PR.

mapLabel :: forall trash a b sym rIn rOut rBase
   . IsSymbol sym
  => RowCons sym a rBase rIn
  => RowCons sym b rBase rOut
  => SProxy sym
  -> (a -> b)
  -> Variant rIn
  -> Variant rOut
mapLabel p f r =
  -- NOTE: This coerce is safe as we know `rBase` is subset of `rOut`. `expand` could
  -- be  used instead, but than you need to provide `Union` instances when it's used.
  on p (inj p <<< f) (unsafeCoerce :: Variant rBase -> Variant rOut) r
@leestephenn
Copy link

I know of a few places that needed something like this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants