[Haskell-cafe] parse error on input `'

2009-04-25 Thread siso dagbovie
Hi,

I've defined the following datatype with haskell

data Graph a b = Empty | Context a b  Graph a b

But I am having the error message:  parse error on input `'  .
I am wondering what it is wrong with my definition. How can I fix this?
Thanks in advance.


Kind regards


  ___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] parse error on input `'

2009-04-25 Thread Daniel Fischer
Am Samstag 25 April 2009 19:29:30 schrieb siso dagbovie:
 Hi,

 I've defined the following datatype with haskell

 data Graph a b = Empty | Context a b  Graph a b

 But I am having the error message:  parse error on input `'  .
 I am wondering what it is wrong with my definition. How can I fix this?
 Thanks in advance.


A constructor symbol has to start with a colon, so make it

data Graph a b = Empty | Context a b : Graph a b

(or :: if you prefer it more symmetric)


 Kind regards

Cheers,
Daniel
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] parse error on input `'

2009-04-25 Thread Jochem Berndsen
siso dagbovie wrote:
 I've defined the following datatype with haskell

 data Graph a b = Empty | Context a b  Graph a b

 But I am having the error message:  parse error on input `'  .
 I am wondering what it is wrong with my definition. How can I fix this?

Constructors have to start with a capital or a : (colon).
So changing your definition into
data Graph a b = Empty | Context a b : Graph a b
will work.

If you want you can define
() = (:)
and use the  symbol for constructing graphs (not in pattern matches
though).

HTH,

-- 
Jochem Berndsen | joc...@functor.nl
GPG: 0xE6FABFAB
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Parse error on input |

2007-05-31 Thread Akijmo

Hi everyone.
I am new to this Forum, Haskell and i am german, so i am sorry for noob
failures or spelling mistakes.

I am currently learning for an informatic exam (11th class) and i tried to
code a function to sum a polynom with a pair of polynoms... (I actually want
to to code a polynomdivision in which i need this)

But I get the parse error mentioned in the headline. It is referring to the
first line of the case differentiation.
Hopefully you can help me, here's the code:

polyplusd :: Polynom - (Polynom, Polynom) - Polynom
polyplusd [] p = p
polyplusd p [] = p
polyplusd p@((g1,e1):p1) (n, (q@((g2,e2):p2))
| g1g2 = (g1,e1):(polyplusd p1 (n,q))
| g2g1 = (g2,e2):(polyplusd p (n,p2))
| g1==g2  e1+e2 /=0 =(g1, e1+e2):(polyplusd 
p1 (n,p2))
| otherwise = polyplusd p1 (n,p2)
-- 
View this message in context: 
http://www.nabble.com/Parse-error-on-input-%22%7C%22-tf3847082.html#a10895849
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Parse error on input |

2007-05-31 Thread Robin Green
You neglected a ) - remember to count your parentheses in future when
you get an error directly after a parenthesised expression.

-- 
Robin

On Thu, 31 May 2007 08:09:23 -0700 (PDT)
Akijmo [EMAIL PROTECTED] wrote:

 
 Hi everyone.
 I am new to this Forum, Haskell and i am german, so i am sorry for
 noob failures or spelling mistakes.
 
 I am currently learning for an informatic exam (11th class) and i
 tried to code a function to sum a polynom with a pair of polynoms...
 (I actually want to to code a polynomdivision in which i need this)
 
 But I get the parse error mentioned in the headline. It is referring
 to the first line of the case differentiation.
 Hopefully you can help me, here's the code:
 
 polyplusd :: Polynom - (Polynom, Polynom) - Polynom
 polyplusd [] p = p
 polyplusd p [] = p
 polyplusd p@((g1,e1):p1) (n, (q@((g2,e2):p2))
   | g1g2 = (g1,e1):(polyplusd p1 (n,q))
   | g2g1 = (g2,e2):(polyplusd p (n,p2))
   | g1==g2  e1+e2 /=0 =(g1,
 e1+e2):(polyplusd p1 (n,p2)) | otherwise = polyplusd p1 (n,p2)

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Parse error on input |

2007-05-31 Thread Dan Weston
The second argument of the second line of the definition does not match 
the expected type. (Polynom,Polynom) is a tuple, not a list, so 
[]::(a,a) is not well typed for any a.


Dan

Akijmo wrote:

Hi everyone.
I am new to this Forum, Haskell and i am german, so i am sorry for noob
failures or spelling mistakes.

I am currently learning for an informatic exam (11th class) and i tried to
code a function to sum a polynom with a pair of polynoms... (I actually want
to to code a polynomdivision in which i need this)

But I get the parse error mentioned in the headline. It is referring to the
first line of the case differentiation.
Hopefully you can help me, here's the code:

polyplusd :: Polynom - (Polynom, Polynom) - Polynom
polyplusd [] p = p
polyplusd p [] = p
polyplusd p@((g1,e1):p1) (n, (q@((g2,e2):p2))
| g1g2 = (g1,e1):(polyplusd p1 (n,q))
| g2g1 = (g2,e2):(polyplusd p (n,p2))
| g1==g2  e1+e2 /=0 =(g1, e1+e2):(polyplusd 
p1 (n,p2))
| otherwise = polyplusd p1 (n,p2)



___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Parse error on input |

2007-05-31 Thread Akijmo

thx much green... this helped for the parser failure.

Dan you were right too, cause now i got the interfering types [(Int,Int)]
and Polynom for line 2.
But i fixed this by replacing it with ([],[])
So thx much guys :D



greenrd wrote:
 
 You neglected a ) - remember to count your parentheses in future when
 you get an error directly after a parenthesised expression.
 
 -- 
 Robin
 
 On Thu, 31 May 2007 08:09:23 -0700 (PDT)
 Akijmo [EMAIL PROTECTED] wrote:
 
 
 Hi everyone.
 I am new to this Forum, Haskell and i am german, so i am sorry for
 noob failures or spelling mistakes.
 
 I am currently learning for an informatic exam (11th class) and i
 tried to code a function to sum a polynom with a pair of polynoms...
 (I actually want to to code a polynomdivision in which i need this)
 
 But I get the parse error mentioned in the headline. It is referring
 to the first line of the case differentiation.
 Hopefully you can help me, here's the code:
 
 polyplusd :: Polynom - (Polynom, Polynom) - Polynom
 polyplusd [] p = p
 polyplusd p [] = p
 polyplusd p@((g1,e1):p1) (n, (q@((g2,e2):p2))
  | g1g2 = (g1,e1):(polyplusd p1 (n,q))
  | g2g1 = (g2,e2):(polyplusd p (n,p2))
  | g1==g2  e1+e2 /=0 =(g1,
 e1+e2):(polyplusd p1 (n,p2)) | otherwise = polyplusd p1 (n,p2)
 
 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe
 
 

-- 
View this message in context: 
http://www.nabble.com/Parse-error-on-input-%22%7C%22-tf3847082.html#a10899124
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe