[Haskell-beginners] small expression evaluator
Petr Novotnik
pnovotnik at googlemail.com
Wed Mar 23 13:55:22 CET 2011
Hello Henk-Jan,
many thanks for your answer. Yes, I could do what you propose. But I
still wonder if it is possible or not to the "lifting" as I mentioned
earlier.
Again thanks for answering,
pete.
On 03/22/2011 01:43 PM, Henk-Jan van Tuyl wrote:
> On Tue, 22 Mar 2011 10:14:57 +0100, Henk-Jan van Tuyl
> <hjgtuyl at chello.nl> wrote:
>
>> On Tue, 22 Mar 2011 08:56:45 +0100, Petr Novotnik
>> <pnovotnik at googlemail.com> wrote:
>>
>>> data Person = Person {
>>> personName :: String
>>> , personAge :: Int
>>> }
>>> deriving (Show)
>>>
>>> exampleExpr :: Bool
>>> exampleExpr = (VConst 99) .==. (VFunc personAge) $ Person "pete" 99
>>>
>>>
>>> I was wondering, whether it'd be possible to enable defining
>>> expression without the Value data constructors, i.e.
>>>
>>>
>>> 99 .==. personAge $ Person "pete" 99
>>
>> You can write:
>> 99 == personAge (Person "pete" 99)
>>
>
> Or you could write:
> c .==. f = \x -> c == f x
>
> test = 99 .==. personAge $ Person "pete" 99
>
> The .==. operator is not symmetrical in this case, of course
>
> Regards,
> Henk-Jan van Tuyl
>
>
More information about the Beginners
mailing list