Skip to content

Bidirectional marshalling between Haskell and Dhall #1492

Open
@sjakobi

Description

@sjakobi

In #1485 (comment) @jiegillet brought up the idea of representing decoders and encoders in a single type inspired by tomland's Codec:

About module for encoding and decoding, it's an out-there suggestion but, the way tomland encodes and decodes toml is with a bi-directional codec, something like

data Codec a = 
    Codec { fromDhall  :: Expr Src Void -> Extractor Src Void a
            toDhall :: a -> Expr Src Void
            dhallType :: Expr Src Void
            }

It's pretty nice to keep the symmetry, and this way you always have to implement both encoders and decoders at the same time.

What I'm wondering right now is what we would do about types where there is no bijection between Dhall and Haskell, like Word.

I also wonder how the types would work out for the combined record and union de-and-encoders and their helpers like constructor and encodeConstructor.

Metadata

Metadata

Assignees

No one assigned

    Labels

    discussmarshallingMarshalling between Dhall and Haskell

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions