Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mthadley/elm-byte
Working with Bytes in Elm.
https://github.com/mthadley/elm-byte
byte elm
Last synced: about 1 month ago
JSON representation
Working with Bytes in Elm.
- Host: GitHub
- URL: https://github.com/mthadley/elm-byte
- Owner: mthadley
- License: mit
- Created: 2017-03-05T01:31:50.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2021-06-23T19:25:31.000Z (over 3 years ago)
- Last Synced: 2024-10-12T17:41:15.229Z (2 months ago)
- Topics: byte, elm
- Language: Elm
- Homepage: http://package.elm-lang.org/packages/mthadley/elm-byte/latest
- Size: 5.86 KB
- Stars: 2
- Watchers: 2
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# elm-byte
A library for working with 8-bit unsigned integers with type safety.
If you are trying to work with byte-sized values in your program, you can use the `Byte` type
exposed in this library instead of the native `Int`. This will give you better
type safety as you wont do things like accidentally add an `Int` somewhere and suddenly
have a value like `2340023`, where you meant to have something much smaller. This
can be particularly useful if you are trying to simulate hardware or other
low level, 8-bit operations.```elm
module Example exposing (..)import Byte
import Carryresult : Bool -- False
result =
Byte.add (Byte.fromInt 132) (Byte.fromInt 245)
|> Byte.toInt
|> (<) 255resultWithCarry : Bool -- True
resultwithCarry =
Byte.addc (Byte.fromInt 132) (Byte.fromInt 245)
|> Carry.check
```