
I feel like the type with Map is not very nice (as map can be
anything).
Given the simplicity of year parsing , how about traditional
```
data DateTime = DT Int Int Int
timeP :: Parser DateTime
timeP = DT <*> p <$> p <$> p where
p = integer <* char '/'
```
Olaf Klinke
You could emulate this with some custom parser combinators on top of any monadic parser combinator library such as attoparsec or megaparsec.
keyed :: (Ord key, Functor parser) => key -> parser a -> parser (Map key a) keyed key = fmap (singleton key)
Then, assuming 'char' and 'digitChar' exists in the parser library, you may write
integer = some digitChar logline = fmap mconcat $ sequence [ keyed "year" (integer <* char '/'), keyed "month" (integer <* char '/'), keyed "day" (integer <* char ' '), -- etc. ]
Olaf _______________________________________________ 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.