Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify 'Codec' abstraction #263

Closed
chshersh opened this issue May 7, 2020 · 0 comments · Fixed by #265
Closed

Simplify 'Codec' abstraction #263

chshersh opened this issue May 7, 2020 · 0 comments · Fixed by #265
Assignees
Labels
codec Conversion between TOML and custom user data types refactoring

Comments

@chshersh
Copy link
Contributor

chshersh commented May 7, 2020

Currently, we have the following Codec abstract data type:

data Codec r w c a = Codec
    { codecRead :: r a
    , codecWrite :: c -> w a
    }

But in this library it's used only for TomlCodec:

type TomlCodec a = Codec Env St a a

It could be a good simplification to combine two and have

data Codec in out = Codec
    { codecRead :: TomlEnv out
    , codecWrite :: in -> TomlState out
    }

type TomlCodec a = Codec a a

What do you think? With this approach, we can have a single module Toml.Codec with all general functions, encoding and decoding functions instead of two modules Toml.Monad and Toml.Code

@chshersh chshersh added codec Conversion between TOML and custom user data types refactoring labels May 7, 2020
@chshersh chshersh added this to the v1.3.0.0: Big update milestone May 7, 2020
@vrom911 vrom911 changed the title [RFC] Simplify 'Codec' abstraction Simplify 'Codec' abstraction May 7, 2020
@vrom911 vrom911 self-assigned this May 7, 2020
vrom911 added a commit that referenced this issue May 7, 2020
chshersh added a commit that referenced this issue May 7, 2020
* [#263] Simplify 'Codec' abstraction

Resolves #263

* Apply suggestions from code review

Co-authored-by: Dmitrii Kovanikov <kovanikov@gmail.com>

* Fix

Co-authored-by: Dmitrii Kovanikov <kovanikov@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
codec Conversion between TOML and custom user data types refactoring
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants