They match, but some take arguments. Ignoring the version number 4
, the encoding [5,0]
means an SVariant
with zero alternatives, basically a sum type with no constructors, AKA Void
:
data Void
On the other hand [3,0]
means an SProduct
with zero fields, namely a type with a single nullary constructor, AKA ()
:
data () = ()
I'd suggest looking at sum and product types other than these "degenerate" ones, and studying the output of pretty
-printing the schemas alongside their serializations:
import Codec.Winery
import qualified Data.ByteString as B
import Data.Proxy
import Prettyprinter
main = do
let s = schema (Proxy :: Proxy (Either Int String))
print $ B.unpack . serialiseSchema $ s
print $ pretty s
The encoding and pretty-printed schema here are:
[4,5,2,4,76,101,102,116,3,1,16,5,82,105,103,104,116,3,1,2,7]
Left Integer | Right [Char]
which means:
[4 -- version 4
,5,2 -- SVariant with 2 alternatives, namely:
,4,76,101,102,116 -- 4-character constructor "Left" for
,3,1 -- SProduct with 1 field
,16 -- consisting of an SInteger
,5,82,105,103,104,116 -- 5-character constructor "Right" for
,3,1 -- SProduct with 1 field
,2 -- consisting of an SVector
,7] -- of SChar