Skip to content

Implement Hashable for UUIDv4 #1

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

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions spago.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package:
dependencies:
- arrays
- assert
- console
- control
- effect
- foldable-traversable
- gen
- integers
- maybe
- partial
- prelude
- quickcheck
- random
- strings
- unordered-collections
name: uuidv4
workspace:
extra_packages: {}
package_set:
url: https://github.com/raw/purescript/package-sets/psc-0.15.4-20221024/packages.json
4 changes: 4 additions & 0 deletions src/UUID/Random.purs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Prelude

import Control.Alternative (guard)
import Data.Array as Array
import Data.Hashable (class Hashable, hash)
import Data.Int as Int
import Data.Maybe (Maybe, fromJust)
import Data.String as String
Expand All @@ -24,6 +25,9 @@ import Partial.Unsafe (unsafePartial)
-- | A type for version 4 (random) UUIDs.
data UUIDv4 = UUIDv4 String (Array Int)

instance Hashable UUIDv4 where
hash (UUIDv4 s _) = hash s

instance Eq UUIDv4 where
eq (UUIDv4 a _) (UUIDv4 b _) = a == b

Expand Down