@@ -21,15 +21,13 @@ module Data.Schematic
2121 , ParseResult(..)
2222 , withRepr
2323 , field
24− , (<:&>)
2524 ) where
2625
27−import Control.Applicative
2826import Control.Monad.Validation
2927import Data.Aeson as J
3028import Data.Aeson.Types as J
3129import Data.ByteString.Lazy as BL
32−import Data.Functor.Identity
30+import Data.Functor.Identity as F
3331import Data.Kind
3432import Data.Schematic.Helpers
3533import Data.Schematic.JsonSchema
@@ -39,13 +37,14 @@ import Data.Schematic.Schema
3937import Data.Schematic.Utils
4038import Data.Schematic.Validation
4139import Data.Scientific
42−import Data.Singletons.Prelude
40+import Data.Singletons.Prelude hiding ((:.))
4341import Data.Singletons.TypeLits
4442import Data.Tagged
4543import Data.Text as T
4644import Data.Union
4745import qualified Data.Vector as V
48−import Data.Vinyl
46+import Data.Vinyl as V
47+import Data.Vinyl.Functor
4948
5049
5150parseAndValidateJson
@@ -131,7 +130,7 @@ decodeAndValidateVersionedWithMList _ mlist bs = case decode bs of
131130
132131decodeAndValidateVersionedWithPureMList
133132 :: proxy versioned
134− -> MList Identity (MapSnd (AllVersions versioned))
133+ -> MList F.Identity (MapSnd (AllVersions versioned))
135134 -> BL.ByteString
136135 -> ParseResult (JsonRepr (Head (MapSnd (AllVersions versioned))))
137136decodeAndValidateVersionedWithPureMList a b c =
@@ -141,20 +140,11 @@ decodeAndValidateVersionedWithPureMList a b c =
141140
142141type Constructor a
143142 = forall b. FSubset (FieldsOf a) b (FImage (FieldsOf a) b)
144− => Tagged (FieldsOf a) (Rec FieldRepr b)
143+ => Rec (Tagged (FieldsOf a) :. FieldRepr) b
145144 -> JsonRepr ('SchemaObject (FieldsOf a))
146145
147146withRepr :: Constructor a
148−withRepr = ReprObject . unTagged . fmap fcast
149−
150−(<:&>)
151− :: Applicative m
152− => m (FieldRepr fns)
153− -> m (Rec FieldRepr b)
154− -> m (Rec FieldRepr (fns ': b))
155−(<:&>) = liftA2 (:&)
156−
157−infixr 7 <:&>
147+withRepr = ReprObject . rmap (unTagged . getCompose) . fcast
158148
159149class Representable s where
160150 type Repr s :: Type
@@ -194,7 +184,7 @@ type family FieldsOf (s :: Schema) :: [(Symbol, Schema)] where
194184type FieldConstructor fn =
195185 forall fs. (Representable (ByField fn fs (FIndex fn fs)))
196186 => Repr (ByField fn fs (FIndex fn fs))
197− -> Tagged fs (FieldRepr '(fn, (ByField fn fs (FIndex fn fs))))
187+ -> (Tagged fs :. FieldRepr) '(fn, (ByField fn fs (FIndex fn fs)))
198188
199189field :: forall fn. KnownSymbol fn => FieldConstructor fn
200−field = Tagged . construct (sing :: Sing fn) Proxy
190+field = Compose . Tagged . construct (sing :: Sing fn) Proxy