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

New design #98

Open
adamgundry opened this issue Oct 8, 2022 · 0 comments · May be fixed by #101
Open

New design #98

adamgundry opened this issue Oct 8, 2022 · 0 comments · May be fixed by #101

Comments

@adamgundry
Copy link
Owner

I've been thinking about a new design for the API, which does not rely on Symbol as the kind of base units, and does not require the quasi-quoter to write literals.

The library should provide this:

data UnitKind

type Unit = UnitKind -> Type

Now user code can define empty datatypes representing base units, and type synonyms for units:

data U_m :: UnitKind -> Type
data U_s :: UnitKind -> Type
data U_kg :: UnitKind -> Type

type U_N = U_kg *: U_m :/ U_s ^: 2

and at the value level:

m :: Num a => Quantity a U_m
m = MkQuantity 1

_N :: Num a => Quantity a U_N
_N = MkQuantity 1

thus we can write:

5 *: _N /: m :: Quantity Int (U_N /: U_m)
@adamgundry adamgundry linked a pull request Oct 9, 2022 that will close this issue
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

Successfully merging a pull request may close this issue.

1 participant