diff --git a/src/Network/Ethereum/Web3/Contract.purs b/src/Network/Ethereum/Web3/Contract.purs index b2615c3..4b0bb45 100644 --- a/src/Network/Ethereum/Web3/Contract.purs +++ b/src/Network/Ethereum/Web3/Contract.purs @@ -159,10 +159,10 @@ deployContract txOptions deployByteCode args = eth_sendTransaction txdata mkDataField - :: forall selector a rep fields l + :: forall selector a rep fields . IsSymbol selector => Generic a rep - => GRecordFieldsIso rep fields l + => GRecordFieldsIso rep fields => GenericABIEncode rep => Proxy (Tagged selector a) -> Record fields diff --git a/src/Network/Ethereum/Web3/Solidity/Event.purs b/src/Network/Ethereum/Web3/Solidity/Event.purs index 5f0fa63..14caaab 100644 --- a/src/Network/Ethereum/Web3/Solidity/Event.purs +++ b/src/Network/Ethereum/Web3/Solidity/Event.purs @@ -75,11 +75,11 @@ parseChange (Change change) anonymous = do pure $ Event a b combineChange - :: forall afields al a arep bfields bl b brep c cfields + :: forall afields a arep bfields b brep c cfields . Generic a arep => Generic b brep - => GRecordFieldsIso arep afields al - => GRecordFieldsIso brep bfields bl + => GRecordFieldsIso arep afields + => GRecordFieldsIso brep bfields => Row.Union afields bfields cfields => Row.Nub cfields cfields => Newtype c (Record cfields) @@ -93,12 +93,12 @@ class IndexedEvent a b c | c -> a b where isAnonymous :: Proxy c -> Boolean decodeEventDef - :: forall afields al a arep bfields bl b brep c cfields + :: forall afields a arep bfields b brep c cfields . Generic a arep - => GRecordFieldsIso arep afields al + => GRecordFieldsIso arep afields => GenericABIDecode arep => ArrayParser arep - => GRecordFieldsIso brep bfields bl + => GRecordFieldsIso brep bfields => Generic b brep => GenericABIDecode brep => Row.Union afields bfields cfields @@ -122,10 +122,10 @@ class instance ( ArrayParser arep - , GRecordFieldsIso arep afields al + , GRecordFieldsIso arep afields , Generic a arep , GenericABIDecode arep - , GRecordFieldsIso brep bfields bl + , GRecordFieldsIso brep bfields , Generic b brep , GenericABIDecode brep , Row.Union afields bfields cfields diff --git a/src/Network/Ethereum/Web3/Solidity/Internal.purs b/src/Network/Ethereum/Web3/Solidity/Internal.purs index 99b0fc0..4fd4818 100644 --- a/src/Network/Ethereum/Web3/Solidity/Internal.purs +++ b/src/Network/Ethereum/Web3/Solidity/Internal.purs @@ -14,51 +14,48 @@ import Data.Symbol (class IsSymbol) import Prim.Row as Row import Record as Record import Type.Proxy (Proxy(..)) -import Type.RowList (class RowListAppend, Cons, Nil) import Unsafe.Coerce (unsafeCoerce) -class GRecordFieldsIso :: forall k1. Type -> Row Type -> k1 -> Constraint -class GRecordFieldsIso rep fields k | rep -> k, k -> rep fields where - gToRecordFields :: Proxy k -> rep -> Record fields - gFromRecordFields :: Proxy k -> Record fields -> rep +class GRecordFieldsIso rep fields | rep -> fields where + gToRecordFields :: rep -> Record fields + gFromRecordFields :: Record fields -> rep -instance GRecordFieldsIso NoArguments () Nil where - gToRecordFields _ _ = {} - gFromRecordFields _ _ = NoArguments +instance GRecordFieldsIso NoArguments () where + gToRecordFields _ = {} + gFromRecordFields _ = NoArguments -else instance GRecordFieldsIso a r rl => GRecordFieldsIso (Constructor name a) r (Cons name rl Nil) where - gToRecordFields _ (Constructor a) = gToRecordFields (Proxy @rl) a - gFromRecordFields _ r = Constructor (gFromRecordFields (Proxy @rl) r) +else instance GRecordFieldsIso a r => GRecordFieldsIso (Constructor name a) r where + gToRecordFields (Constructor a) = gToRecordFields a + gFromRecordFields r = Constructor (gFromRecordFields r) else instance ( IsSymbol s , Row.Cons s a () r , Row.Lacks s () ) => - GRecordFieldsIso (Argument (Tagged s a)) r (Cons s a Nil) where - gToRecordFields _ (Argument a) = Record.insert (Proxy @s) (untagged a) {} - gFromRecordFields _ r = Argument (tagged $ Record.get (Proxy @s) r) + GRecordFieldsIso (Argument (Tagged s a)) r where + gToRecordFields (Argument a) = Record.insert (Proxy @s) (untagged a) {} + gFromRecordFields r = Argument (tagged $ Record.get (Proxy @s) r) else instance - ( GRecordFieldsIso as ra rla - , GRecordFieldsIso bs rb rlb - , RowListAppend rla rlb rl + ( GRecordFieldsIso as ra + , GRecordFieldsIso bs rb , Row.Union ra rb r , Row.Nub r r ) => - GRecordFieldsIso (Product as bs) r rl where - gToRecordFields _ (Product as bs) = - Record.merge (gToRecordFields (Proxy @rla) as) (gToRecordFields (Proxy @rlb) bs) + GRecordFieldsIso (Product as bs) r where + gToRecordFields (Product as bs) = + Record.merge (gToRecordFields as) (gToRecordFields bs) - gFromRecordFields _ r = + gFromRecordFields r = let - as = gFromRecordFields (Proxy @rla) (unsafeCoerce r) - bs = gFromRecordFields (Proxy @rlb) (unsafeCoerce r) + as = gFromRecordFields (unsafeCoerce r) + bs = gFromRecordFields (unsafeCoerce r) in Product as bs -toRecord :: forall a rep fields l. Generic a rep => GRecordFieldsIso rep fields l => a -> Record fields -toRecord a = gToRecordFields (Proxy :: Proxy l) (from a) +toRecord :: forall a rep fields. Generic a rep => GRecordFieldsIso rep fields => a -> Record fields +toRecord a = gToRecordFields $ from a -fromRecord :: forall a rep fields l. Generic a rep => GRecordFieldsIso rep fields l => Record fields -> a -fromRecord a = to $ gFromRecordFields (Proxy :: Proxy l) a +fromRecord :: forall a rep fields. Generic a rep => GRecordFieldsIso rep fields => Record fields -> a +fromRecord a = to $ gFromRecordFields a