Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {-# LANGUAGE AllowAmbiguousTypes #-}
- {-# LANGUAGE FlexibleContexts #-}
- {-# LANGUAGE RankNTypes #-}
- {-# LANGUAGE TypeFamilies #-}
- module Foo1 where
- import Data.Foldable
- class Foo t where
- type FooPType t :: * -- Base type.
- type FooFType t :: * -> * -- Container type.
- defPs :: FooFType t (FooPType t) -- Initialized container.
- -- An attempt at a universal testing function valid for all types, t,
- -- of class Foo for which `FooFType t` is a foldable functor.
- tst :: forall t.
- ( Foo t
- , Functor (FooFType t)
- , Foldable (FooFType t)
- ) => FooPType t
- tst = (head . toList) defPs
- Foo1.hs:30:23: error:
- • Couldn't match type ‘FooPType t0’ with ‘FooPType t’
- Expected type: FooFType t0 (FooPType t)
- Actual type: FooFType t0 (FooPType t0)
- NB: ‘FooPType’ is a type function, and may not be injective
- The type variable ‘t0’ is ambiguous
- • In the first argument of ‘head . toList’, namely ‘defPs’
- In the expression: (head . toList) defPs
- In an equation for ‘tst’: tst = (head . toList) defPs
- • Relevant bindings include
- tst :: FooPType t (bound at Foo1.hs:30:1)
Add Comment
Please, Sign In to add comment