*Main> fmap (+1) Nothing Nothing *Main> fmap (+1) (Just 3) Just 4 *Main> :r [1 of 1] Compiling Main ( lec13.hs, interpreted ) lec13.hs:28:34: error: • Couldn't match expected type ‘Maybe (b, String)’ with actual type ‘Parser b’ • In the expression: f x In a case alternative: Just (x, s') -> f x In the expression: case p s of Nothing -> Nothing Just (x, s') -> f x • Relevant bindings include f :: a -> Parser b (bound at lec13.hs:25:13) (>>=) :: Parser a -> (a -> Parser b) -> Parser b (bound at lec13.hs:25:9) | 28 | Just (x, s') -> f x | ^^^ Failed, no modules loaded. Prelude> :r [1 of 1] Compiling Main ( lec13.hs, interpreted ) lec13.hs:29:37: error: • Couldn't match expected type ‘Maybe (b, String)’ with actual type ‘String -> Maybe (b, String)’ • Probable cause: ‘g’ is applied to too few arguments In the expression: g In the expression: let P g = f x in g In a case alternative: Just (x, s') -> let P g = f x in g • Relevant bindings include g :: String -> Maybe (b, String) (bound at lec13.hs:28:40) f :: a -> Parser b (bound at lec13.hs:25:13) (>>=) :: Parser a -> (a -> Parser b) -> Parser b (bound at lec13.hs:25:9) | 29 | in g | ^ Failed, no modules loaded. Prelude> :r [1 of 1] Compiling Main ( lec13.hs, interpreted ) lec13.hs:29:34: error: • Couldn't match expected type ‘String -> Maybe (b, String)’ with actual type ‘Parser b’ • The function ‘f’ is applied to two arguments, but its type ‘a -> Parser b’ has only one In the expression: (f x) s' In a case alternative: Just (x, s') -> (f x) s' • Relevant bindings include f :: a -> Parser b (bound at lec13.hs:26:13) (>>=) :: Parser a -> (a -> Parser b) -> Parser b (bound at lec13.hs:26:9) | 29 | Just (x, s') -> (f x) s' | ^^^^^^^^ Failed, no modules loaded. *Main> :t null null :: Foldable t => t a -> Bool *Main> parse ";abc" (sat (\ c -> c == 'c')) Nothing *Main> parse ";abc" (sat (\ c -> c == ';')) Just (';',"abc") *Main> parse ";abc" (char 'c') Nothing *Main> parse ";abc" (char ';') Just (';',"abc") *Main> parse ";abc" (string ";a") Just (";a","bc") *Main> parse ";abc" (string ";b") Nothing *Main> :t parse parse :: String -> Parser a -> Maybe (a, String) *Main> parse ";abc" (string ";abcd") Nothing *Main> parse ";abc" (string ";abc") Just (";abc","") *Main> parse ";abc" (string "") Just ("",";abc") *Main> parse ";abc" (string ";abcd") Nothing *Main>