[clean-list] questions

Miles Egan miles@caddr.com
Mon, 24 Nov 2003 11:08:54 -0800


--=-DNlhgvAnlAbPLPJUKXC5
Content-Type: text/plain
Content-Transfer-Encoding: quoted-printable

On Sun, 2003-11-23 at 15:10, Fergus Henderson wrote:
> On 20-Nov-2003, Tomasz Zielonka <t.zielonka@zodiac.mimuw.edu.pl> wrote:
> > On Thu, Nov 20, 2003 at 05:26:36PM +0100, Jenda Krynicky wrote:
> > >=20
> > > If e.g. I want to make sure that the stuff entered by the user is a=20
> > > date in YYYY-MM-DD format I definitely do not want to spend twenty=20
> > > 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=
=20
> > > and the day is reasonable, but you'd do that outside the parser as=20
> > > well.)
> >=20
> > date =3D do
> >     yyyy <- count 4 digit
> >     char '-'
> >     mm <- count 2 digit
> >     char '-'
> >     dd <- count 2 digit
> >     return (yyyy, mm, dd)
> >=20
> > Is it really so long and cryptic?
>=20
> No!  "\d{4}" is cryptic!  "yyyy <- count 4 digit" is elegant and reasonab=
ly
> concise without being cryptic.
>=20
> But if you really want to make it as concise as possible, at the expense
> of readability, like the regexp, it could be a lot more concise:
>=20
> 	do { y <- count 4 digit; char '-'; m <- count 2 digit; char '-';
>              d <- count 2 digit; return (y, m, d); }

Does clean support do notation?  I couldn't find any mention of it in
the docs.

--=20
Miles Egan <miles@caddr.com>

--=-DNlhgvAnlAbPLPJUKXC5
Content-Type: application/pgp-signature; name=signature.asc
Content-Description: This is a digitally signed message part

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (GNU/Linux)

iD8DBQA/wldEU4Jq/wH1PVERAsXcAKDaSZLZOQ/r3S1O+wh/w0CuDpBAjACeLDnN
bRUFTKWh1H9qVYKJ8k6B9F8=
=VjOH
-----END PGP SIGNATURE-----

--=-DNlhgvAnlAbPLPJUKXC5--