parser error in pattern

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

parser error in pattern

kolli kolli
hey can anyone tell me what is parser error in parser??Plz help me out

_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Fwd: parser error in pattern

kolli kolli


---------- Forwarded message ----------
From: kolli kolli <[hidden email]>
Date: Mon, Oct 17, 2011 at 3:43 PM
Subject: parser error in pattern
To: [hidden email]


hey can anyone tell me what is parser error in pattern??Plz help me out


_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: parser error in pattern

Ivan Lazar Miljenovic
In reply to this post by kolli kolli
On 18 October 2011 08:43, kolli kolli <[hidden email]> wrote:
> hey can anyone tell me what is parser error in parser??Plz help me out

It's when the parser can't parse what it's provided.... providing the
code that caused the problem and the actual error message is required
for a more detailed explanation.

--
Ivan Lazar Miljenovic
[hidden email]
IvanMiljenovic.wordpress.com

_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: parser error in pattern

kolli kolli
after parsing a string i am evaluating it...
string if t1 then t2 else t3
my code is
eval1 :: Term ->  Maybe Term                  
eval1(If Tru t2 t3) = Just t2
eval1(If Fls t2 t3) = Just t3
eval1(If t1 t2 t3) =  case eval t1
                    where eval1(If t1 t2 t3) =  Just t1         
         
eval :: Term -> Term
eval (IsZero Zero) = Tru
eval (Zero) = Zero
eval(Pred Zero) = Pred Zero

On Mon, Oct 17, 2011 at 3:46 PM, Ivan Lazar Miljenovic <[hidden email]> wrote:
On 18 October 2011 08:43, kolli kolli <[hidden email]> wrote:
> hey can anyone tell me what is parser error in parser??Plz help me out

It's when the parser can't parse what it's provided.... providing the
code that caused the problem and the actual error message is required
for a more detailed explanation.

--
Ivan Lazar Miljenovic
[hidden email]
IvanMiljenovic.wordpress.com


_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: parser error in pattern

Ivan Lazar Miljenovic
On 18 October 2011 08:56, kolli kolli <[hidden email]> wrote:

> after parsing a string i am evaluating it...
> string if t1 then t2 else t3
> my code is
> eval1 :: Term ->  Maybe Term
> eval1(If Tru t2 t3) = Just t2
> eval1(If Fls t2 t3) = Just t3
> eval1(If t1 t2 t3) =  case eval t1
>                     where eval1(If t1 t2 t3) =  Just t1
>
> eval :: Term -> Term
> eval (IsZero Zero) = Tru
> eval (Zero) = Zero
> eval(Pred Zero) = Pred Zero

Your case statement is incomplete for starters...

Can you please provide the actual error message as well?  Your
definition of Term would also be useful.

>
> On Mon, Oct 17, 2011 at 3:46 PM, Ivan Lazar Miljenovic
> <[hidden email]> wrote:
>>
>> On 18 October 2011 08:43, kolli kolli <[hidden email]> wrote:
>> > hey can anyone tell me what is parser error in parser??Plz help me out
>>
>> It's when the parser can't parse what it's provided.... providing the
>> code that caused the problem and the actual error message is required
>> for a more detailed explanation.
>>
>> --
>> Ivan Lazar Miljenovic
>> [hidden email]
>> IvanMiljenovic.wordpress.com
>
>



--
Ivan Lazar Miljenovic
[hidden email]
IvanMiljenovic.wordpress.com

_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: parser error in pattern

Ivan Lazar Miljenovic
On 18 October 2011 09:08, kolli kolli <[hidden email]> wrote:

> actual error message is
>
> homework2.lhs:137:20: parse error on input `where'
>
> data Term = Tru
>           | Fls
>           | If Term Term Term
>           | Zero
>           | Succ Term
>           | Pred Term
>           | IsZero Term
>           deriving Eq
>

As I said, the error is from your incorrect usage of the case
statement; it _should_ look something like:

case foo of
    bar -> baz
    bar' -> baz'

>
>
>
>
> On Mon, Oct 17, 2011 at 4:03 PM, Ivan Lazar Miljenovic
> <[hidden email]> wrote:
>>
>> On 18 October 2011 08:56, kolli kolli <[hidden email]> wrote:
>> > after parsing a string i am evaluating it...
>> > string if t1 then t2 else t3
>> > my code is
>> > eval1 :: Term ->  Maybe Term
>> > eval1(If Tru t2 t3) = Just t2
>> > eval1(If Fls t2 t3) = Just t3
>> > eval1(If t1 t2 t3) =  case eval t1
>> >                     where eval1(If t1 t2 t3) =  Just t1
>> >
>> > eval :: Term -> Term
>> > eval (IsZero Zero) = Tru
>> > eval (Zero) = Zero
>> > eval(Pred Zero) = Pred Zero
>>
>> Your case statement is incomplete for starters...
>>
>> Can you please provide the actual error message as well?  Your
>> definition of Term would also be useful.
>>
>> >
>> > On Mon, Oct 17, 2011 at 3:46 PM, Ivan Lazar Miljenovic
>> > <[hidden email]> wrote:
>> >>
>> >> On 18 October 2011 08:43, kolli kolli <[hidden email]> wrote:
>> >> > hey can anyone tell me what is parser error in parser??Plz help me
>> >> > out
>> >>
>> >> It's when the parser can't parse what it's provided.... providing the
>> >> code that caused the problem and the actual error message is required
>> >> for a more detailed explanation.
>> >>
>> >> --
>> >> Ivan Lazar Miljenovic
>> >> [hidden email]
>> >> IvanMiljenovic.wordpress.com
>> >
>> >
>>
>>
>>
>> --
>> Ivan Lazar Miljenovic
>> [hidden email]
>> IvanMiljenovic.wordpress.com
>
>



--
Ivan Lazar Miljenovic
[hidden email]
IvanMiljenovic.wordpress.com

_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: parser error in pattern

Ivan Lazar Miljenovic
On 18 October 2011 09:14, kolli kolli <[hidden email]> wrote:
> I didnt understand properly but made changes according to what I
> understood..Its still giving me the same error
>
> eval1(If t1 t2 t3) =  case (If t1 t2 t3) of
>                     eval1(If t1 t2 t3) ->  Just t1

You can't do that.... if you want the result to be "Just t1", why not
just have "eval1 (If t1 t2 t3) = Just t1", with no case or where
statement?

>
>
> On Mon, Oct 17, 2011 at 4:10 PM, Ivan Lazar Miljenovic
> <[hidden email]> wrote:
>>
>> On 18 October 2011 09:08, kolli kolli <[hidden email]> wrote:
>> > actual error message is
>> >
>> > homework2.lhs:137:20: parse error on input `where'
>> >
>> > data Term = Tru
>> >           | Fls
>> >           | If Term Term Term
>> >           | Zero
>> >           | Succ Term
>> >           | Pred Term
>> >           | IsZero Term
>> >           deriving Eq
>> >
>>
>> As I said, the error is from your incorrect usage of the case
>> statement; it _should_ look something like:
>>
>> case foo of
>>    bar -> baz
>>    bar' -> baz'
>>
>> >
>> >
>> >
>> >
>> > On Mon, Oct 17, 2011 at 4:03 PM, Ivan Lazar Miljenovic
>> > <[hidden email]> wrote:
>> >>
>> >> On 18 October 2011 08:56, kolli kolli <[hidden email]> wrote:
>> >> > after parsing a string i am evaluating it...
>> >> > string if t1 then t2 else t3
>> >> > my code is
>> >> > eval1 :: Term ->  Maybe Term
>> >> > eval1(If Tru t2 t3) = Just t2
>> >> > eval1(If Fls t2 t3) = Just t3
>> >> > eval1(If t1 t2 t3) =  case eval t1
>> >> >                     where eval1(If t1 t2 t3) =  Just t1
>> >> >
>> >> > eval :: Term -> Term
>> >> > eval (IsZero Zero) = Tru
>> >> > eval (Zero) = Zero
>> >> > eval(Pred Zero) = Pred Zero
>> >>
>> >> Your case statement is incomplete for starters...
>> >>
>> >> Can you please provide the actual error message as well?  Your
>> >> definition of Term would also be useful.
>> >>
>> >> >
>> >> > On Mon, Oct 17, 2011 at 3:46 PM, Ivan Lazar Miljenovic
>> >> > <[hidden email]> wrote:
>> >> >>
>> >> >> On 18 October 2011 08:43, kolli kolli <[hidden email]>
>> >> >> wrote:
>> >> >> > hey can anyone tell me what is parser error in parser??Plz help me
>> >> >> > out
>> >> >>
>> >> >> It's when the parser can't parse what it's provided.... providing
>> >> >> the
>> >> >> code that caused the problem and the actual error message is
>> >> >> required
>> >> >> for a more detailed explanation.
>> >> >>
>> >> >> --
>> >> >> Ivan Lazar Miljenovic
>> >> >> [hidden email]
>> >> >> IvanMiljenovic.wordpress.com
>> >> >
>> >> >
>> >>
>> >>
>> >>
>> >> --
>> >> Ivan Lazar Miljenovic
>> >> [hidden email]
>> >> IvanMiljenovic.wordpress.com
>> >
>> >
>>
>>
>>
>> --
>> Ivan Lazar Miljenovic
>> [hidden email]
>> IvanMiljenovic.wordpress.com
>
>



--
Ivan Lazar Miljenovic
[hidden email]
IvanMiljenovic.wordpress.com

_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe