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

Added bits functions #1319

Merged
merged 1 commit into from
Oct 25, 2024
Merged

Added bits functions #1319

merged 1 commit into from
Oct 25, 2024

Conversation

Izaakwltn
Copy link
Collaborator

@Izaakwltn Izaakwltn commented Oct 22, 2024

Added a few functions to coalton-library/bits.

dpb and ldb mimic their Common Lisp counterparts, following the same argument order.

print-bits is a handy debugging tool for printing bit types to a specified number of bits.

@stylewarning
Copy link
Member

Please keep the original argument order where the bytespec comes first. I actually think that's better for currying.

I would also get rid of the bytespecs entirely. Just pass them as curried args.

@Izaakwltn
Copy link
Collaborator Author

Please keep the original argument order where the bytespec comes first. I actually think that's better for currying.

I would also get rid of the bytespecs entirely. Just pass them as curried args.

Changed the order, removed Bytespec

library/bits.lisp Outdated Show resolved Hide resolved
library/bits.lisp Outdated Show resolved Hide resolved
library/bits.lisp Outdated Show resolved Hide resolved
library/bits.lisp Outdated Show resolved Hide resolved
library/bits.lisp Outdated Show resolved Hide resolved
(cl:ldb (cl:byte size position) bitstring)))

(declare bits->string (Bits :a => UFix -> :a -> String))
(define (bits->string width x)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since x is a type class constrained type, it's not guaranteed to be a compatible Lisp value with FORMAT. you need to convert it to an integer for this to work, or extract the bits one by one

i suggest either fixing this or removing it

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good, I removed it.

It would fit better in a potential future Coalton formatting library anyways.

@stylewarning stylewarning merged commit 19965eb into main Oct 25, 2024
33 checks passed
@stylewarning stylewarning deleted the bits-overhaul branch October 25, 2024 03:46
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 this pull request may close these issues.

2 participants