-- existentielle Typen -- Aufruf mit ghci -fglasgow-exts module EXtest where import Char data InhPaar = forall a. IP a (a -> Bool) | EmptyPair --- Der Datentyp \verb|InhPaar| hat die Konstruktoren -- -- IP :: forall a. a -> (a -> Bool) -> InhPaar -- EmptyPair :: InhPaar -- Folgender Ausdruck ist wohlgetypt: testliste = [IP 3 even, IP 1 (< 2), EmptyPair, IP 'c' isUpper]::[InhPaar] -- korekt: f :: InhPaar -> Maybe Bool f (IP wert fun) = Just (fun wert ) f EmptyPair = Nothing test1 = f (head testliste) maptestliste = map f testliste -- Falsch -- f1 :: InhPaar -> a -> Bool -- f1 (IP wert fun) = fun -- f2 :: InhPaar -> a -- f2 (IP wert fun) = wert ----- Tests: -- let g (IP x y) = x -- ergibt Typfehler