1{-# OPTIONS -fprint-explicit-kinds #-}
2{-# LANGUAGE AllowAmbiguousTypes #-}
5 ( module Data.Schematic.JsonSchema
6 , module Data.Schematic.Helpers
7 , module Data.Schematic.Lens
8 , module Data.Schematic.Migration
9 , module Data.Schematic.Schema
10 , decodeAndValidateJson
11 , parseAndValidateJson
12 , parseAndValidateJsonBy
13 , parseAndValidateTopVersionJson
14 , parseAndValidateWithMList
15 , decodeAndValidateVersionedWithMList
16 , decodeAndValidateVersionedWithPureMList
25import Control.Monad.Validation
27import Data.Aeson.Types as J
28import Data.ByteString.Lazy as BL
29import Data.Functor.Identity as F
30import Data.Schematic.DSL
31import Data.Schematic.Helpers
32import Data.Schematic.JsonSchema
33import Data.Schematic.Lens
34import Data.Schematic.Migration
35import Data.Schematic.Schema
36import Data.Schematic.Validation
37import Data.Singletons.Prelude hiding ((:.))
42parseAndValidateTopVersionJson
43 :: forall proxy (v :: Versioned)
44 . (SingI (TopVersion (AllVersions v)))
47 -> ParseResult (JsonRepr (TopVersion (AllVersions v)))
48parseAndValidateTopVersionJson _ v =
49 case parseEither parseJSON v of
50 Left s -> DecodingError $ T.pack s
54 validateJsonRepr (sing :: Sing (TopVersion (AllVersions v))) [] jsonRepr
55 res = runIdentity . runValidationTEither $ validate
57 Left em -> ValidationError em
58 Right () -> Valid jsonRepr
60parseAndValidateWithMList
64 -> m (ParseResult (JsonRepr (Head revisions)))
65parseAndValidateWithMList MNil v = pure $ parseAndValidateJson v
66parseAndValidateWithMList (Tagged f :&& tl) v =
67 case parseAndValidateJsonBy Proxy v of
68 Valid a -> pure $ Valid a
70 pr <- parseAndValidateWithMList tl v
73 ValidationError _ -> do
74 pr <- parseAndValidateWithMList tl v
80 . (J.FromJSON (JsonRepr schema), TopLevel schema, SingI schema)
82 -> ParseResult (JsonRepr schema)
83decodeAndValidateJson bs = case decode bs of
84 Nothing -> DecodingError "malformed json"
85 Just x -> parseAndValidateJson x
87decodeAndValidateVersionedWithMList
90 -> MList m (MapSnd (AllVersions versioned))
92 -> m (ParseResult (JsonRepr (Head (MapSnd (AllVersions versioned)))))
93decodeAndValidateVersionedWithMList _ mlist bs = case decode bs of
94 Nothing -> pure $ DecodingError "malformed json"
95 Just x -> parseAndValidateWithMList mlist x
97decodeAndValidateVersionedWithPureMList
99 -> MList F.Identity (MapSnd (AllVersions versioned))
101 -> ParseResult (JsonRepr (Head (MapSnd (AllVersions versioned))))
102decodeAndValidateVersionedWithPureMList a b c =
103 runIdentity $ decodeAndValidateVersionedWithMList a b c
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list