fork download
  1. {-# LANGUAGE FlexibleInstances #-}
  2. {-# LANGUAGE OverlappingInstances #-}
  3.  
  4. class IsList a where
  5. isList :: a -> Bool
  6.  
  7. instance IsList a where
  8. isList x = False
  9.  
  10. instance IsList [a] where
  11. isList x = True
  12.  
  13. isList2 :: (IsList a) => a -> Bool
  14. isList2 = isList
  15.  
  16. main = do
  17. print (isList (42 :: Int))
  18. print (isList [42 :: Int])
  19. print (isList2 (42 :: Int))
  20. print (isList2 [42 :: Int])
  21.  
Success #stdin #stdout 0s 5720KB
stdin
Standard input is empty
stdout
False
True
False
True