Skip to content

Instantly share code, notes, and snippets.

@cjlarose
Created September 19, 2015 00:26
Show Gist options
  • Save cjlarose/20992322b22a2bba637e to your computer and use it in GitHub Desktop.
Save cjlarose/20992322b22a2bba637e to your computer and use it in GitHub Desktop.
Default implementation
class Bytes a where
toBytes :: a -> List UInt8
width :: Int
addWithCarry :: a -> a -> (Tuple Boolean a)
default addWithCarry a b = case (addLists (toBytes a) (toBytes b)) of
(Cons 0 sum) -> (Tuple false a)
(Cons 1 sum) -> (Tuple true a)
otherwise -> error
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment