Skip to content

Instantly share code, notes, and snippets.

@goolord
Created May 13, 2021 15:51
Show Gist options
  • Save goolord/ccccfc23a09509b65248ebed51bc300b to your computer and use it in GitHub Desktop.
Save goolord/ccccfc23a09509b65248ebed51bc300b to your computer and use it in GitHub Desktop.
useful debugging stuff
showBits :: FiniteBits a => a -> String
showBits = fmap (bool '0' '1') . bitList
traceWith :: Show b => (a -> b) -> a -> a
traceWith f x = traceShow (f x) x
bitList :: FiniteBits a => a -> [Bool]
bitList x = let size = finiteBitSize x
in [testBit x i | i <- enumFromThenTo size (size - 1) 0]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment