What do you think about Mercury?

Manuel M. T. Chakravarty chak@cse.unsw.edu.au
Tue, 10 Apr 2001 11:16:27 +1000


qrczak@knm.org.pl (Marcin 'Qrczak' Kowalczyk) wrote,

> Mon, 9 Apr 2001 14:30:01 +1000, Fergus Henderson <fjh@cs.mu.oz.au> pisze:
> 
> > For an example of this, I've attached a program for solving the
> > 8-queens problem;
> 
> Here is mine, also using the list monad together with the state monad
> (uses StateT [] and not ListT State, so the state is restored during
> backtracking and not permanent).
> 
> import Monad;import MonadState;main=mapM_(\s->mapM_ putStrLn$[]:[take
>  8$replicate i '.'++'Q':repeat '.'|i<-s])$evalStateT(mapM(\i->msum[do
>  (/)<-get;guard$i/j;put(\x y->y/=j&&x+y/=i+j&&x-y/=i-j&&x/y);return j
>  |j<-a])a)(\_ _->True);a=[0..7]

I always knew that inside Haskell there is a Perl trying to
get out!

Manuel