Skip to content

Instantly share code, notes, and snippets.

@s9gf4ult
Last active February 24, 2017 07:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save s9gf4ult/5e338a2fc69f63ba36002544b3cc1b1f to your computer and use it in GitHub Desktop.
Save s9gf4ult/5e338a2fc69f63ba36002544b3cc1b1f to your computer and use it in GitHub Desktop.
import Data.Time
class Diffable a where
type Diff a :: *
diff :: a -> a -> Diff a
addDiff :: Diff a -> a -> a
instance {-# OVERLAPPABLE #-} (Num a) => Diffable a where
type Diff a = a
diff = (-)
addDiff = (+)
instance Diffable UTCTime where
type Diff UTCTime = NominalDiffTime
diff = diffUTCTime
addDiff = addUTCTime
-- Conflicting family instance declarations:
-- Diff a -- Defined at src/Peridot/Diffable.hs:11:8
-- Diff UTCTime -- Defined at src/Peridot/Diffable.hs:16:8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment