Created
November 9, 2018 00:47
-
-
Save kozross/c7111bc195dd9f1480130bd810e9ff8b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
newtype AtomP = AtomP Word64 | |
view :: AtomP -> Maybe (Bool, Word64) | |
view x = let mask = complement (bit 63 .|. bit 62) | |
raw = coerce x in | |
if | testBit raw 63 -> Nothing | |
| testBit raw 62 -> Just (False, pext64 raw mask) | |
| otherwise -> Just (True, pext64 raw mask) | |
-- I want to expose a view of AtomP as a Maybe (Bool, Word64) on the basis of the function above. | |
-- I want the view to be read-only (so for pattern matching). |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.