Hi I am studing Haskell, attoparsec was suggested to me for parsing a file, now I must to understand how to use it; somebody gave me this piece of code:
#
type Environment = M.Map String String
import Data.Attoparsec (maybeResult)
import qualified Data.Attoparsec.Char8 as A
import qualified Data.ByteString.Char8 as B
environment :: A.Parser Environment
environment = M.fromList <$> A.sepBy entry A.endOfLine
parseEnvironment = maybeResult .flip A.feed B.empty . A.parse environment
spaces = A.many $ A.char ' '
entry = (,) <$> upTo ':' <*> upTo ';'
upTo delimiter = B.unpack <$> A.takeWhile (A.notInClass $ delimiter : " ")
<* (spaces >> A.char delimiter >> spaces)
that works very well, but I do not know why: what the reason of using flip, is it not easier to put the argument of A.feed in a different order? and why is there B.empty? is there some tutorial about that I can study? thanks in advance