[Haskell] Existential Types - код не компилируется
От: awk  
Дата: 11.02.10 11:28
Оценка:
Пытаюсь скомпилировать такой код:

{-# LANGUAGE ExistentialQuantification #-}
module Ex where

  import Maybe

  class (EX a) where
    cool :: a -> Bool

  process :: forall a b. (EX a, EX b) => a -> (a -> Maybe b) -> Maybe b
  process x processor = processor x

  myProcessor :: forall a b. (EX a, EX b) => a -> Maybe b
  myProcessor x = Nothing

  doStuff :: forall a. (EX a) => a -> Bool
  doStuff x = let newX = process x myProcessor
              in False


Никак не пойму, почему появляется ошибка

exist.hs:16:25:
    Ambiguous type variable `b' in the constraint:
      `EX b' arising from a use of `process' at exist.hs:16:25-45
    Probable fix: add a type signature that fixes these type variable(s)


Объясните, пожалуйста, что не так, и как это можно исправить (с примером, если можно ).
 
Подождите ...
Wait...
Пока на собственное сообщение не было ответов, его можно удалить.