I think specific formats can be parsed with attoparsec (Data.Attoparsec.Text):

p = do 
   year <- yearP
   char '/'
   month <- monthP
   char '/'
   ....
   return (year, month, ...)

You may also use cassava to parse csv-like files, or Frames for type-safe parsing. With Frames you may custom readers ( http://acowley.github.io/Frames/#orgfa57664 ) with complex pattern-matching, this will require typing skills though.

ср, 17 апр. 2019 г. в 12:30, Magicloud Magiclouds <magicloud.magiclouds@gmail.com>:
Hi,

I saw this function in some web tools, pretty useful when parsing log
or so. So I wonder if Haskell has similar libs already.

Sample:

Input line: "2019/04/17 17:27 User magicloud runs command ls."

Pattern: "${year}/${month}/${day} ${hour}:${minute} User ${username}
runs command ${command}."

Output: toList [ ("year", "2019"), ("month", "04") , etc ]

--
竹密岂妨流水过
山高哪阻野云飞

And for G+, please use magiclouds#gmail.com.
_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.


--
Sincerely, Stanislav Chernichkin.