unwrap package:aeson-schemas

Defines a QuasiQuoter to extract a schema within the given schema. The base schema needs to be defined in a separate module. For example:
-- | MyFoo ~ Object [schema| { b: Maybe Bool } |]
type MyFoo = [unwrap| MySchema.foo.nodes[] |]
If the schema is imported qualified, you can use parentheses to distinguish it from the expression:
type MyFoo = [unwrap| (MyModule.Schema).foo.nodes[] |]
You can then use the type alias as usual:
parseBar :: MyFoo -> String
parseBar = maybe "null" show . [get| .b |]

foo = map parseBar [get| result.foo.nodes[] |]
The syntax is mostly the same as get, except the operations run on the type itself, instead of the values. Differences from get:
  • x! is only valid if x is a Maybe a type. Returns a, the type wrapped in the Maybe.
  • x? is the same as x!.
  • x[] is only valid if x is a [a] type. Returns a, the type contained in the list.
  • x@# is only valid if x is a SumType. Returns the type at that branch in the sum type.