Add Interpret/Inject instances for []

This commit is contained in:
Gabriel Gonzalez 2017-08-21 11:36:59 -07:00
parent fa51d5e40e
commit 27264a0ba4

View File

@ -455,6 +455,9 @@ instance Interpret a => Interpret (Maybe a) where
instance Interpret a => Interpret (Vector a) where
autoWith opts = vector (autoWith opts)
instance Interpret a => Interpret [a] where
autoWith = fmap (fmap Data.Vector.toList) autoWith
instance (Interpret a, Interpret b) => Interpret (a, b) where
autoWith = fmap (\R2{..} -> (_1, _2)) . autoWith
@ -743,6 +746,9 @@ instance Inject a => Inject (Vector a) where
InputType embedIn declaredIn = injectWith options
instance Inject a => Inject [a] where
injectWith = fmap (contramap Data.Vector.fromList) injectWith
-- | (a, b) is mapped to { _1 = a, _2 = b }
instance (Inject a, Inject b) => Inject (a, b) where
injectWith = fmap (contramap adapt) injectWith