fork download
  1. {-# LANGUAGE TypeFamilies #-}
  2.  
  3. type family F a
  4.  
  5. data A = A Int
  6. data B = B Double
  7.  
  8. type instance F A = Int
  9. type instance F B = Double
  10.  
  11. class Get a where
  12. get :: a -> F a
  13.  
  14. instance Get A where
  15. get (A x) = x
  16.  
  17. instance Get B where
  18. get (B x) = x
  19.  
  20. main = print $ (get (A 3), get (B 2.0))
  21.  
Success #stdin #stdout 0s 6264KB
stdin
Standard input is empty
stdout
(3,2.0)