fork(4) download
  1. {-# LANGUAGE FlexibleInstances, TypeFamilies, IncoherentInstances #-}
  2.  
  3. class Foo a where
  4. foo :: a
  5.  
  6. instance a ~ Int => Foo (String -> a) where
  7. foo = length
  8.  
  9. instance a ~ String => Foo a where
  10. foo = "world"
  11.  
  12. main = do
  13. print $ foo "hello"
  14. print $ foo
Success #stdin #stdout 0s 4592KB
stdin
Standard input is empty
stdout
5
"world"