Created
April 5, 2011 20:32
-
-
Save brentonashworth/904481 to your computer and use it in GitHub Desktop.
Polymorphic on return type
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# 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