mirror of
https://github.com/NorfairKing/autodocodec.git
synced 2024-12-02 09:52:01 +03:00
got rid of some done todos
This commit is contained in:
parent
e04fed62a7
commit
c8c3b179b5
@ -34,10 +34,12 @@ import Data.Validity.Containers ()
|
|||||||
import Data.Validity.Text ()
|
import Data.Validity.Text ()
|
||||||
import GHC.Generics (Generic)
|
import GHC.Generics (Generic)
|
||||||
|
|
||||||
-- TODO think about putting this value in a separate package or directly in autodocodec
|
-- | A JSON Schema
|
||||||
--
|
--
|
||||||
-- http://json-schema.org/understanding-json-schema/reference/index.html
|
-- http://json-schema.org/understanding-json-schema/reference/index.html
|
||||||
--
|
--
|
||||||
|
-- Contrary to a 'Codec', values of this type should be finite.
|
||||||
|
--
|
||||||
-- NOTE: This schema roundtrips to JSON, but it cannot expres everything that a fully-featured json-schema may be able to express.
|
-- NOTE: This schema roundtrips to JSON, but it cannot expres everything that a fully-featured json-schema may be able to express.
|
||||||
data JSONSchema
|
data JSONSchema
|
||||||
= AnySchema
|
= AnySchema
|
||||||
@ -295,7 +297,7 @@ jsonSchemaVia = (`evalState` S.empty) . go
|
|||||||
s <- go c
|
s <- go c
|
||||||
pure [(k, (Optional (Just (hr, toJSONVia c mr)), s, mdoc))]
|
pure [(k, (Optional (Just (hr, toJSONVia c mr)), s, mdoc))]
|
||||||
MapCodec _ _ c -> goObject c
|
MapCodec _ _ c -> goObject c
|
||||||
PureCodec _ -> pure [] -- TODO show something ?
|
PureCodec _ -> pure []
|
||||||
ApCodec oc1 oc2 -> liftA2 (++) (goObject oc1) (goObject oc2)
|
ApCodec oc1 oc2 -> liftA2 (++) (goObject oc1) (goObject oc2)
|
||||||
|
|
||||||
uncurry3 :: (a -> b -> c -> d) -> ((a, b, c) -> d)
|
uncurry3 :: (a -> b -> c -> d) -> ((a, b, c) -> d)
|
||||||
|
@ -108,7 +108,7 @@ instance FromJSON Example where
|
|||||||
--
|
--
|
||||||
-- 1. We can define recursive types
|
-- 1. We can define recursive types
|
||||||
-- 2. We can encode, decode, and document a recursive type finitely.
|
-- 2. We can encode, decode, and document a recursive type finitely.
|
||||||
-- 3. TODO We can roundtrip its json schema through json.
|
-- 3. We can roundtrip its json schema through json.
|
||||||
data Recursive
|
data Recursive
|
||||||
= Base Int
|
= Base Int
|
||||||
| Recurse Recursive
|
| Recurse Recursive
|
||||||
|
@ -53,7 +53,6 @@ data Codec context input output where
|
|||||||
-- | Encode 'Scientific' to a @number@ value, and decode a @number@ value as a 'Scientific'.
|
-- | Encode 'Scientific' to a @number@ value, and decode a @number@ value as a 'Scientific'.
|
||||||
--
|
--
|
||||||
-- NOTE: We use 'Scientific' here because that is what aeson uses.
|
-- NOTE: We use 'Scientific' here because that is what aeson uses.
|
||||||
-- TODO: Can we do this without 'Scientific'? It has too many footguns.
|
|
||||||
NumberCodec ::
|
NumberCodec ::
|
||||||
-- | Name of the @number@, for error messages and documentation.
|
-- | Name of the @number@, for error messages and documentation.
|
||||||
!(Maybe Text) ->
|
!(Maybe Text) ->
|
||||||
@ -247,7 +246,7 @@ showCodecABit = ($ "") . (`evalState` S.empty) . go 0
|
|||||||
RequiredKeyCodec k c mdoc -> (\s -> showParen (d > 10) $ showString "RequiredKeyCodec " . showsPrec d k . showString " " . showsPrec d mdoc . showString " " . s) <$> go 11 c
|
RequiredKeyCodec k c mdoc -> (\s -> showParen (d > 10) $ showString "RequiredKeyCodec " . showsPrec d k . showString " " . showsPrec d mdoc . showString " " . s) <$> go 11 c
|
||||||
OptionalKeyCodec k c mdoc -> (\s -> showParen (d > 10) $ showString "OptionalKeyCodec " . showsPrec d k . showString " " . showsPrec d mdoc . showString " " . s) <$> go 11 c
|
OptionalKeyCodec k c mdoc -> (\s -> showParen (d > 10) $ showString "OptionalKeyCodec " . showsPrec d k . showString " " . showsPrec d mdoc . showString " " . s) <$> go 11 c
|
||||||
OptionalKeyWithDefaultCodec k c shownDefault _ mdoc -> (\s -> showParen (d > 10) $ showString "OptionalKeyWithDefaultCodec " . showsPrec d k . showString " " . s . showString " " . showsPrec d shownDefault . showString " " . showsPrec d mdoc) <$> go 11 c
|
OptionalKeyWithDefaultCodec k c shownDefault _ mdoc -> (\s -> showParen (d > 10) $ showString "OptionalKeyWithDefaultCodec " . showsPrec d k . showString " " . s . showString " " . showsPrec d shownDefault . showString " " . showsPrec d mdoc) <$> go 11 c
|
||||||
PureCodec _ -> pure $ showString "PureCodec" -- TODO add show instance?
|
PureCodec _ -> pure $ showString "PureCodec"
|
||||||
ApCodec oc1 oc2 -> (\s1 s2 -> showParen (d > 10) $ showString "ApCodec " . s1 . showString " " . s2) <$> go 11 oc1 <*> go 11 oc2
|
ApCodec oc1 oc2 -> (\s1 s2 -> showParen (d > 10) $ showString "ApCodec " . s1 . showString " " . s2) <$> go 11 oc1 <*> go 11 oc2
|
||||||
|
|
||||||
-- | Map the output part of a codec
|
-- | Map the output part of a codec
|
||||||
|
Loading…
Reference in New Issue
Block a user