git.iko.soy/typeable/schematic
on master help sign in
more readable types
ad93274Denis Redozubov
src/Data/Schematic.hs+5−5
@@ -87,11 +87,11 @@ instance {-# OVERLAPPABLE #-}
87 Right x -> Valid x
87 Right x -> Valid x
88
88
89parseAndValidateVersionedJson
89parseAndValidateVersionedJson
90− :: forall proxy v. (SingI (Reverse (AllVersions v)), Migratable (Reverse (AllVersions v)))
90+ :: forall proxy v. (SingI (AllVersions v), Migratable (AllVersions v))
91 => proxy v
91 => proxy v
92 -> J.Value
92 -> J.Value
93− -> ParseResult (JsonRepr (Snd (Head (Reverse (AllVersions v)))))
93+ -> ParseResult (JsonRepr (Snd (Head (AllVersions v))))
94−parseAndValidateVersionedJson _ v = mparse (sing :: Sing (Reverse (AllVersions v))) v
94+parseAndValidateVersionedJson _ v = mparse (sing :: Sing (AllVersions v)) v
95
95
96decodeAndValidateJson
96decodeAndValidateJson
97 :: forall schema
97 :: forall schema
@@ -103,10 +103,10 @@ decodeAndValidateJson bs = case decode bs of
103 Just x -> parseAndValidateJson x
103 Just x -> parseAndValidateJson x
104
104
105decodeAndValidateVersionedJson
105decodeAndValidateVersionedJson
106− :: (Migratable (Reverse (AllVersions versioned)), SingI (Reverse (AllVersions versioned)))
106+ :: (Migratable (AllVersions versioned), SingI (AllVersions versioned))
107 => proxy versioned
107 => proxy versioned
108 -> BL.ByteString
108 -> BL.ByteString
109− -> ParseResult (JsonRepr (Snd (Head (Reverse (AllVersions versioned)))))
109+ -> ParseResult (JsonRepr (Snd (Head (AllVersions versioned))))
110decodeAndValidateVersionedJson vp bs = case decode bs of
110decodeAndValidateVersionedJson vp bs = case decode bs of
111 Nothing -> DecodingError "malformed json"
111 Nothing -> DecodingError "malformed json"
112 Just x -> parseAndValidateVersionedJson vp x
112 Just x -> parseAndValidateVersionedJson vp x
src/Data/Schematic/Migration.hs+1−1
@@ -87,7 +87,7 @@ type family ElemOf (e :: k) (l :: [(a,k)]) :: Constraint where
87
87
88-- | Extracts revision/schema pairs from @Versioned@ in reverse order.
88-- | Extracts revision/schema pairs from @Versioned@ in reverse order.
89type family AllVersions (vd :: Versioned) :: [(Revision, Schema)] where
89type family AllVersions (vd :: Versioned) :: [(Revision, Schema)] where
90− AllVersions ('Versioned s ms) = AllVersions' '[ '("initial", s) ] ms
90+ AllVersions ('Versioned s ms) = Reverse (AllVersions' '[ '("initial", s) ] ms)
91
91
92type family AllVersions' (acc :: [(Revision, Schema)]) (ms :: [Migration]) = (r :: [(Revision, Schema)]) where
92type family AllVersions' (acc :: [(Revision, Schema)]) (ms :: [Migration]) = (r :: [(Revision, Schema)]) where
93 AllVersions' acc '[] = acc
93 AllVersions' acc '[] = acc