Skip to content

Instantly share code, notes, and snippets.

@brentonashworth
Created April 5, 2011 20:32
Show Gist options
  • Save brentonashworth/904481 to your computer and use it in GitHub Desktop.
Save brentonashworth/904481 to your computer and use it in GitHub Desktop.
Polymorphic on return type
{-# LANGUAGE TypeSynonymInstances #-}
class TwoOf a where
twoOf :: String -> a
instance TwoOf Bool where
twoOf str = length str >= 2
instance TwoOf String where
twoOf str = take 2 str
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment