Skip to content

Instantly share code, notes, and snippets.

@Blaisorblade
Last active December 18, 2015 03:18
Show Gist options
  • Save Blaisorblade/5716721 to your computer and use it in GitHub Desktop.
Save Blaisorblade/5716721 to your computer and use it in GitHub Desktop.
Why does this not work?
{-# LANGUAGE TypeFamilies #-}
module DeltaInt where
class Changing a where
-- Using type families here is a bit convenient, but means risking trouble later.
type Delta a
nil :: a -> Delta a
apply :: a -> Delta a -> a
diff :: a -> a -> Delta a
instance Changing Integer where
type Delta Integer = Integer
nil = const 0
apply = (+)
diff = (-)
v :: Delta Integer
v = diff 2 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment