Let it go through it!
nextWord "an apple"
Since "an apple" does not match the pattern with [] , we are in the second case. Substituting in 'a': "n apple" for c : cs , we get:
nextWord ('a':"n apple") | isSpace 'a' = ([], "n apple") | otherwise = ('a': word, other) where (word, other) = nextWord "n apple"
isSpace 'a' is False , so this is simplified to
nextWord ('a':"n apple") = ('a': word, other) where (word, other) = nextWord "n apple"
Similarly, for nextWord "n apple" we get
nextWord ('n':" apple") = ('n': word, other) where (word, other) = nextWord " apple"
And for nextWord " apple" we get
nextWord (' ':"apple") | isSpace ' ' = ([], "apple") | otherwise = ('a': word, other) where (word, other) = nextWord "n apple"
Which makes it easier
nextWord (' ':"apple") = ([], "apple")
Substituting back into our expression for nextWord "n apple" , we get
nextWord ('n':" apple") = ('n': word, other) where (word, other) = ([], "apple")
which simplifies to
nextWord ('n':" apple") = ('n':[], "apple")
or
nextWord ('n':" apple") = ("n", "apple")
Now, replacing this expression with our expression for nextWord "an apple" , we get
nextWord ('a':"n apple") = ('a': word, other) where (word, other) = ("n", "apple")
which simplifies to
nextWord ('a':"n apple") = ('a':"n", "apple")
or
nextWord ('a':"n apple") = ("an", "apple")