Guest User

Untitled

a guest
Mar 24th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. {-# LANGUAGE AllowAmbiguousTypes #-}
  2. {-# LANGUAGE FlexibleContexts #-}
  3. {-# LANGUAGE RankNTypes #-}
  4. {-# LANGUAGE TypeFamilies #-}
  5.  
  6. module Foo1 where
  7.  
  8. import Data.Foldable
  9.  
  10. class Foo t where
  11. type FooPType t :: * -- Base type.
  12. type FooFType t :: * -> * -- Container type.
  13. defPs :: FooFType t (FooPType t) -- Initialized container.
  14.  
  15. -- An attempt at a universal testing function valid for all types, t,
  16. -- of class Foo for which `FooFType t` is a foldable functor.
  17. tst :: forall t.
  18. ( Foo t
  19. , Functor (FooFType t)
  20. , Foldable (FooFType t)
  21. ) => FooPType t
  22. tst = (head . toList) defPs
  23.  
  24. Foo1.hs:30:23: error:
  25. • Couldn't match type ‘FooPType t0’ with ‘FooPType t’
  26. Expected type: FooFType t0 (FooPType t)
  27. Actual type: FooFType t0 (FooPType t0)
  28. NB: ‘FooPType’ is a type function, and may not be injective
  29. The type variable ‘t0’ is ambiguous
  30. • In the first argument of ‘head . toList’, namely ‘defPs’
  31. In the expression: (head . toList) defPs
  32. In an equation for ‘tst’: tst = (head . toList) defPs
  33. • Relevant bindings include
  34. tst :: FooPType t (bound at Foo1.hs:30:1)
Add Comment
Please, Sign In to add comment