[clean-list] questions
Tomasz Zielonka
t.zielonka@students.mimuw.edu.pl
Thu, 20 Nov 2003 18:08:11 +0100
On Thu, Nov 20, 2003 at 05:26:36PM +0100, Jenda Krynicky wrote:
>
> If e.g. I want to make sure that the stuff entered by the user is a
> date in YYYY-MM-DD format I definitely do not want to spend twenty
> cryptic lines writing a parser where
> /^(\d{4})-(\d{1,2})-(\d{1,2})$/
> suffices. (I know you need to make sure the month is between 1 and 12
> and the day is reasonable, but you'd do that outside the parser as
> well.)
date = do
yyyy <- count 4 digit
char '-'
mm <- count 2 digit
char '-'
dd <- count 2 digit
return (yyyy, mm, dd)
Is it really so long and cryptic?
You get reusability and compositionality for free.
Best regards,
Tom
--
.signature: Too many levels of symbolic links