intPair :: Parser [Integer]
intPair = (\x _ z -> x : z : []) <$> posInt <*> char ' ' <*> posInt
+
+-- Exercise 4
+-- class Applicative f => Alternative f where
+-- empty :: f a
+-- (<|>) :: f a -> f a -> f a
+instance Alternative Parser where
+ empty = Parser(\_ -> Nothing)
+ (Parser p1) <|> (Parser p2) = Parser (\inp -> case (p1 inp) of
+ Nothing -> (p2 inp)
+ Just v -> Just v)
+
+-- exercise 5: int or Uppercase
+intOrUppercase :: Parser ()
+intOrUppercase = ((\_ -> ()) <$> posInt) <|> ((\_ -> ()) <$> (satisfy isUpper))