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

Implement type-safe version of TOML ast #7

Closed
chshersh opened this issue Mar 29, 2018 · 0 comments
Closed

Implement type-safe version of TOML ast #7

chshersh opened this issue Mar 29, 2018 · 0 comments
Assignees
Labels
λ-safe Type safety, validation ast Type of TOML

Comments

@chshersh
Copy link
Contributor

So, currently TOML Value data type allows to have values of different type inside Array. I propose to solve this problem by introducing new TValue data type (or renaming current Value to UValue aka _untyped value) with GADT and DataKinds feature. Basically:

data TomlType = TBool | ...

data Value (t :: TomlType) where
    Bool :: Bool -> Value TBool
    ...

Basically, approach starting from this slide should be used:

I guess we should have UValue and typeCheck :: UValue -> Maybe Value function. Not sure though...

Also, several problems need to be solved. For example, this type also should have typed and untyped version but it's not obvious how to modify it... Let's discuss and see whether it makes sense!

data TOML = TOML
    { tomlPairs       :: HashMap Key     Value
    , tomlTables      :: HashMap TableId TOML
@chshersh chshersh added ast Type of TOML λ-safe Type safety, validation labels Mar 29, 2018
vrom911 added a commit that referenced this issue Mar 29, 2018
vrom911 added a commit that referenced this issue Mar 30, 2018
vrom911 added a commit that referenced this issue Mar 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
λ-safe Type safety, validation ast Type of TOML
Projects
None yet
Development

No branches or pull requests

2 participants