Skip to content

Conversation

@reactormonk
Copy link
Contributor

Also added a test.

@natefaubion
Copy link
Owner

I think this can be formulated without expand:

class VariantInjTagged a b | a -> b where
  injTagged :: Record a -> Variant b

instance variantInjTagged ::
  ( RowToList r1 (RL.Cons sym a RL.Nil)
  , R.Cons sym a () r1
  , R.Cons sym a rx r2
  , IsSymbol sym
  ) =>
  VariantInjTagged r1 r2 where
  injTagged = inj (SProxy :: SProxy sym) <<< get (SProxy :: SProxy sym)

This would allow you to just write throw as:

throw :: forall m r1 r2 a.
  VariantInjTagged r1 r2 =>
  MonadThrow (Variant r2) m =>
  Record r1 ->
  m a
throw = throwError <<< injTagged

I know I originally said that I didn't really want this sugar in Variant core, but I might reconsider. It does seem a but weird to stick this here.

@safareli
Copy link

safareli commented Oct 3, 2019

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

Successfully merging this pull request may close these issues.

3 participants