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

Allow integer quantities for ingredients #110

Open
langston-barrett opened this issue Dec 24, 2019 · 2 comments
Open

Allow integer quantities for ingredients #110

langston-barrett opened this issue Dec 24, 2019 · 2 comments

Comments

@langston-barrett
Copy link
Collaborator

We currently use readFrac to read quantities from recipes stored in JSON/YAML:

instance Yaml.FromJSON Ingredient where
  parseJSON = Yaml.withObject "Ingredient" $ \o -> Ingredient
    <$> (readFrac <$> o .: Text.pack "quantity")
-- snip
readFrac :: String -> Ratio Int
readFrac = -- snip

readFrac requires a string as input, so users must ensure that the quantity field parses as a string, either by unnecessarily adding a denominator, e.g.

    - quantity: 1/1

or by quoting the value:

    quantity: '1'

I think it would be nice to support JSON/YAML integers directly (in addition to fractions), so users could just write:

    quantity: 1

which is more like what I would do in a plain text file.

@Jinbobo
Copy link
Contributor

Jinbobo commented Feb 15, 2020

I'd like to claim this one if no one is working on it

@langston-barrett
Copy link
Collaborator Author

@Jinbobo Go for it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants