GHCi -- thanks ghc team !
Jon Fairbairn
Jon.Fairbairn@cl.cam.ac.uk
Mon, 29 Oct 2001 21:49:05 +0000
--==_Exmh_-294782877P
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable
Eray Ozkural wrote:
> I
> have difficulty using GHCi because I can't define functions interactive=
ly.
> Would it be possible to introduce a mode to do that?
You can do this:
Loading package std ... linking ... done.
Prelude> let f x =3D 1+x
Prelude> f 2
3
Prelude> let {g 1 =3D 1; g n =3D n-1} =
Prelude> g 1
1
Prelude> g 2
1
> That might be a lot more comfortable for sketching a piece of code.
You can't type =
f [] =3D 1
f [x] =3D x
because how would the interpreter know when you'd typed the
whole definition? But using let (without the in) looks like
what you want.
J=F3n
-- =
J=F3n Fairbairn Jon.Fairbairn@cl.cam.ac.u=
k
31 Chalmers Road jf@cl.cam.ac.uk
Cambridge CB1 3SZ +44 1223 570179 (after 14:00 only, please!)
--==_Exmh_-294782877P
Content-Type: application/pgp-signature
-----BEGIN PGP SIGNATURE-----
Version: PGP 6.5.8
Comment: Exmh version 2.3+CL 01/14/2001
iQCVAwUBO93O0TCOaWN2IzVpAQGdwQP/VRgfWZ5xoEC/iSlQnodZycGZB7jzL7Ym
a4MSN9dyde2x32I0fL5iUGfkgiY2z51wmNxVq+rrFGyrsNOpwV9OSnIuUDU/kMM+
oXTqE1FVJiD5tD+bpybSxCzDz9+Lo82/uihTygLOkjM0eWc/bJUyN72qwBeAbvTU
vOhNoPPHnCs=
=p5qs
-----END PGP SIGNATURE-----
--==_Exmh_-294782877P--