Skip to content

Instantly share code, notes, and snippets.

@xenophobia
Created February 17, 2013 04:43
Show Gist options
  • Select an option

  • Save xenophobia/4970216 to your computer and use it in GitHub Desktop.

Select an option

Save xenophobia/4970216 to your computer and use it in GitHub Desktop.
{-# Language FlexibleInstances, ScopedTypeVariables #-}
class AddNType t where
adds :: Int -> t
instance AddNType Int where
adds = id
instance AddNType t => AddNType (Int -> t) where
adds n = \m -> (adds (n+m) :: t)
addN :: AddNType t => t
addN = adds 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment