Skip to content

Instantly share code, notes, and snippets.

@ujihisa
Created July 5, 2010 04:33
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 ujihisa/463997 to your computer and use it in GitHub Desktop.
Save ujihisa/463997 to your computer and use it in GitHub Desktop.
import System
class Hi a where
hi :: a -> String
data Ujihisa = Ujihisa
instance Hi Ujihisa where
hi = "my name is ujihisa"
data Ujm = Ujm
instance Hi Ujm where
hi = "this is a pen"
main = do x <- getArgs
let the_klass = if length x == 1 then Ujihisa else Ujm
print $ hi the_klass
/var/folders/Dz/Dz5WpFSZGUaFLA8jp8kT5E+++TM/-Tmp-/vv6A9jF/341:4:61:
Couldn't match expected type `Ujihisa' against inferred type `Ujm'
In the expression: Ujm
In the expression: if length x == 1 then Ujihisa else Ujm
In the definition of `the_klass':
the_klass = if length x == 1 then Ujihisa else Ujm
/var/folders/Dz/Dz5WpFSZGUaFLA8jp8kT5E+++TM/-Tmp-/vv6A9jF/341:12:7:
Couldn't match expected type `Ujihisa -> String'
against inferred type `[Char]'
In the expression: "my name is ujihisa"
In the definition of `hi': hi = "my name is ujihisa"
In the instance declaration for `Hi Ujihisa'
/var/folders/Dz/Dz5WpFSZGUaFLA8jp8kT5E+++TM/-Tmp-/vv6A9jF/341:16:7:
Couldn't match expected type `Ujm -> String'
against inferred type `[Char]'
In the expression: "this is a pen"
In the definition of `hi': hi = "this is a pen"
In the instance declaration for `Hi Ujm'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment