[Haskell-beginners] A very counterintuitive behaviour of Haskell

Magnus Therning magnus at therning.org
Thu Jan 27 16:31:23 CET 2011


On Thu, Jan 27, 2011 at 15:02, Magnus Therning <magnus at therning.org> wrote:
> On Thu, Jan 27, 2011 at 14:55, Renzo Orsini <renzo.orsini at gmail.com> wrote:
>> In studying Haskell, I produced the following output from GHC:
>>
>> xxx-3:~ xxx$ GHCi
>> GHCi, version 6.12.3: http://www.haskell.org/ghc/  :? for help
>> Loading package ghc-prim ... linking ... done.
>> Loading package integer-gmp ... linking ... done.
>> Loading package base ... linking ... done.
>> Loading package ffi-1.0 ... linking ... done.
>> Prelude> let f 7 = "ok"
>> Prelude> let f x = "no"
>> Prelude> f 3
>> "no"
>> Prelude> f 7
>> "no"
>>
>> I suppose it is correct. However, for someone who is interested in the language, it seems very counterintuitive... Somebody would be so kind to explain to a neophyte this "feature" of the language?
>
> I suppose it comes down to pattern matching being on form, not on value.

What an amazingly wrong answer by me, sorry for the noise ;-)

/M

-- 
Magnus Therning                      OpenPGP: 0xAB4DFBA4
email: magnus at therning.org   jabber: magnus at therning.org
twitter: magthe               http://therning.org/magnus



More information about the Beginners mailing list