module U2Beispiel where -- Maybe-Typ: data Maybe' a = Nothing | Just a --- (kein Erg.) (Ergebnis) deriving Show type Value = Char lookup' :: Eq a => a -> [ (a,Value) ] -> Maybe' Value lookup' x [] = Nothing lookup' x (d:ds) = if x == d1 then Just d2 else lookup' x ds where (d1,d2) = d {- fst :: (a,b) -> a snd :: (a,b) -> b ohne Typkontext "Eq a": ERROR "U:\PUBLI~$I\cbws03\Uebungen\U2BEI~2_.HS":12 - Cannot justify constraints in explicitly typed binding *** Expression : lookup' *** Type : a -> [(a,Value)] -> Maybe' Value *** Given context : () *** Constraints : Eq a -} daten :: [(Integer, Value)] daten = zipWith (,) [ 1 .. 20 ] ['a'..'z'] findChar :: Maybe' Char -> String findChar Nothing = "Nix gefunden" findChar (Just c) = "Gefunden: " ++ [c]