Re: [Haskell-cafe] parse error in pattern, and byte code interpreter
On Sat, Jan 14, 2012 at 18:18, TP wrote: > Times expr1 Plus( expr2 expr3 ) -> OCaml pattern syntax is not the same as Haskell pattern syntax. The correct way to write that pattern is Times expr1 (Plus expr2 expr3) This is consistent with Haskell not using parentheses for function parameters, since all calls are curried. -- brandon s allbery allber...@gmail.com wandering unix systems administrator (available) (412) 475-9364 vm/sms ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Parse error
> It's an improvement. It's still not pretty, but I guess that's as good as > it's going to get... > > Maybe this is an instance of Haskell trying to tell me "if you need to write > a 20-line do-block in the middle of your function, you're doing it wrong". 20 lines is a lot, but I have smaller ones all the time. You need >4 spaces of indent to continue a let. Here's another way to understand why: f = do let x = some big expression y = another big expression x y If you wonder why "multiple let" syntax is needed, well I don't really know for sure, but consider if x and y were mutually recursive. I was annoyed at first with all the indentation but got used to it. I use 4 space indents so it works out ok. Binding with <- or in where can reduce the indentation but is not always appropriate. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Parse error
On 17 Jan 2010, at 11:44, Andrew Coppin wrote: Urg, but that's *ugly*. Is there no way I can reduce the amount of indentation to something more reasonable? main = do putStrLn "Line 1" putStrLn "Line 2" let xs = do x <- [1..10] y <- [1..10] return (x+y) print xs That better? It's an improvement. It's still not pretty, but I guess that's as good as it's going to get... Maybe this is an instance of Haskell trying to tell me "if you need to write a 20-line do-block in the middle of your function, you're doing it wrong". Haskell starts the new indentation level where the following lexeme is (Haskell-98 Report, sec. 2.7). So to reduce indentation, one must start a new line (already mentioned in this thread). This works in Hugs: main = do putStrLn "Line 1" putStrLn "Line 2" let xs = do x <- [1..10] y <- [1..10] return (x+y) print xs The "xs" on a new line looks a bit unusual, and it takes a bit more vertical space, but one gets nice indentation levels. Hans ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Parse error
Daniel Fischer wrote: Am Sonntag 17 Januar 2010 11:33:45 schrieb Andrew Coppin: Urg, but that's *ugly*. Is there no way I can reduce the amount of indentation to something more reasonable? main = do putStrLn "Line 1" putStrLn "Line 2" let xs = do x <- [1..10] y <- [1..10] return (x+y) print xs That better? It's an improvement. It's still not pretty, but I guess that's as good as it's going to get... Maybe this is an instance of Haskell trying to tell me "if you need to write a 20-line do-block in the middle of your function, you're doing it wrong". ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Parse error
On Sun, Jan 17, 2010 at 10:33:45AM +, Andrew Coppin wrote: > Tony Morris wrote: > >main = do > > putStrLn "Line 1" > > putStrLn "Line 2" > > > > let xs = do x <- [1..10] > > y <- [1..10] > > return (x+y) > > > > print xs > > Urg, but that's *ugly*. Is there no way I can reduce the amount of > indentation to something more reasonable? Sure: start a new line and indentation level after every where, let, do or of. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Parse error
Am Sonntag 17 Januar 2010 11:33:45 schrieb Andrew Coppin: > Tony Morris wrote: > > No, but there's a specific reason why GHC consistently refuses to > > accept your perfectly unreasonable code snippet :) > > She sells csh on the sea shore. :-) > > > GHC accepts the following perfectly reasonable code snippet: > > > > main = do > > putStrLn "Line 1" > > putStrLn "Line 2" > > > > let xs = do x <- [1..10] > > y <- [1..10] > > return (x+y) > > > > print xs > > Urg, but that's *ugly*. Is there no way I can reduce the amount of > indentation to something more reasonable? main = do putStrLn "Line 1" putStrLn "Line 2" let xs = do x <- [1..10] y <- [1..10] return (x+y) print xs That better? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Parse error
Tony Morris wrote: No, but there's a specific reason why GHC consistently refuses to accept your perfectly unreasonable code snippet :) She sells csh on the sea shore. :-) GHC accepts the following perfectly reasonable code snippet: main = do putStrLn "Line 1" putStrLn "Line 2" let xs = do x <- [1..10] y <- [1..10] return (x+y) print xs Urg, but that's *ugly*. Is there no way I can reduce the amount of indentation to something more reasonable? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Parse error
Am Sonntag 17 Januar 2010 11:05:47 schrieb Andrew Coppin: > Is there a specific reason why GHC consistently refuses to accept the > following perfectly reasonable code snippet? Yes, you violated the layout rule. > > main = do > putStrLn "Line 1" > putStrLn "Line 2" > > let xs = do > x <- [1..10] > y <- [1..10] > return (x+y) > > print xs > > No matter which way I rearrange this, it *insists* that there's a parse > error. This is very frustrating, given that it's utterly clear what I > want... It's not. ACLayout.hs:7:11: Empty 'do' construct should give a hint (line 7 is " let xs = do"). The next line after that is indented less than the "xs", so it ends the binding for xs (in fact, the entire let binding group) . You have to indent the lines in the do-block defining xs more than xs itself. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Parse error
No, but there's a specific reason why GHC consistently refuses to accept your perfectly unreasonable code snippet :) GHC accepts the following perfectly reasonable code snippet: main = do putStrLn "Line 1" putStrLn "Line 2" let xs = do x <- [1..10] y <- [1..10] return (x+y) print xs Andrew Coppin wrote: > Is there a specific reason why GHC consistently refuses to accept the > following perfectly reasonable code snippet? > > main = do > putStrLn "Line 1" > putStrLn "Line 2" > > let xs = do >x <- [1..10] >y <- [1..10] >return (x+y) > > print xs > > No matter which way I rearrange this, it *insists* that there's a > parse error. This is very frustrating, given that it's utterly clear > what I want... > > ___ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- Tony Morris http://tmorris.net/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Parse error
let ... in ... I guess GHC is finding where "in" is. 在 2010年 1月 17日 星期日 18:05:47,Andrew Coppin 寫道: > Is there a specific reason why GHC consistently refuses to accept the > following perfectly reasonable code snippet? > > main = do > putStrLn "Line 1" > putStrLn "Line 2" > > let xs = do > x <- [1..10] > y <- [1..10] > return (x+y) > > print xs > > No matter which way I rearrange this, it *insists* that there's a parse > error. This is very frustrating, given that it's utterly clear what I > want... > > ___ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Parse error on input "|"
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)) >> | g1>g2 = (g1,e1):(polyplusd p1 (n,q)) >> | g2>g1 = (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
Re: [Haskell-cafe] Parse error on input "|"
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)) | g1>g2 = (g1,e1):(polyplusd p1 (n,q)) | g2>g1 = (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 "|"
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)) > | g1>g2 = (g1,e1):(polyplusd p1 (n,q)) > | g2>g1 = (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 Thu, 17 Mar 2005 20:42:30 +0100, Dmitri Pissarenko <[EMAIL PROTECTED]> wrote: > Hello! > > In the attachment you will find a file, in which I try to access Java from > Haskell using the Java bridge for functional languages. > > For details see > > http://sourceforge.net/projects/jvm-bridge/ > > and > > http://dapissarenko.com/resources/2005_02_17_eigenvaluesJava/2005_02_17_eigenva > luesJava.pdf > > When I try to compile the attached file using > > ghc +RTS -c -RTS -package javavm -c EigenvalueCalculatorHaskell.hs -o > EigenvalueCalculatorHaskell.o > > I get the error > > EigenvalueCalculatorHaskell.hs:28: parse error on input `putStrLn' > > Unfortunately, I have not the slightest idea about how to fix/isolate it (I > already commented out almost the whole code). > > Please tell me what I could try to correct the error. I appreciate ANY hint. Use 'do {let {foo = baz}; bar }'. And Haskell code look _a lot_ prettier when using the layout to structure the program. -- Friendly, Lemmih ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Parse error
You need { } around the declaration of matrix1. Otherwise the semicolon at the end of its definition is considered to be part of the 'let': let { matrix1 = (array ((1,1),(3,3)) [((1,1), 0.0), ((1,2), 0.0), ((1,3),-2.0), ((2,1), 0.0), ((2,2), 7.0), ((2,3), 0.0), ((3,1), 0), ((3,2), 0), ((3,3), -3)])} ; The layout rule will otherwise add { } as follows: do { let x = 10 ; putStr "hello" ; } --> do { let { x = 10 ; } putStr "hello" ; } which is wrong, because there is no semicolon separating the 'let'-declaration from the 'putStr' expression. A solution is to use layout instead of { ; } or write semicolons in front of declarations: do { let x = 10 ; putStr "hello" } This translates into: do { let { x = 10 } ; putStr "hello" } The semicolon is not part of the 'let' declaration, because it is indented less than 'x' . For more information, see: http://haskell.org/onlinereport/syntax-iso.html#layout Hope this helps, Arthur On 17-mrt-05, at 20:42, Dmitri Pissarenko wrote: Hello! In the attachment you will find a file, in which I try to access Java from Haskell using the Java bridge for functional languages. For details see http://sourceforge.net/projects/jvm-bridge/ and http://dapissarenko.com/resources/2005_02_17_eigenvaluesJava/ 2005_02_17_eigenva luesJava.pdf When I try to compile the attached file using ghc +RTS -c -RTS -package javavm -c EigenvalueCalculatorHaskell.hs -o EigenvalueCalculatorHaskell.o I get the error EigenvalueCalculatorHaskell.hs:28: parse error on input `putStrLn' Unfortunately, I have not the slightest idea about how to fix/isolate it (I already commented out almost the whole code). Please tell me what I could try to correct the error. I appreciate ANY hint. Many thanks in advance Dmitri Pissarenko PS: The source code of the files related to EigenvalueCalculatorHaskell.hs is located at http://dapissarenko.com/resources/2005_02_17_eigenvaluesJava/ 2005_02_17_lik.zip -- Dmitri Pissarenko Software Engineer http://dapissarenko.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Parse error in a package file
Looks like there are a bunch of mis-placed "-L"s in the file. Maybe they need to be quoted? Do you mean this 1) Before: library_dirs = [ "c:/Programme/haskell-jvm-bridge-0.3-RC1/lib/"-L ], After: library_dirs = [ "c:/Programme/haskell-jvm-bridge-0.3-RC1/lib/", "-L" ], 2) Before: extra_libraries = ["stdc++","JVMBridge","JVMInvocation","HaskellJVMBridge"-L,"jvm_imp"], After: extra_libraries = ["stdc++","JVMBridge","JVMInvocation","HaskellJVMBridge","-L",,"jvm_imp"], 3) Before: extra_ld_opts= [ "-Wl,-rpath,c:/Programme/haskell-jvm-bridge-0.3-RC1/lib/"-L ] After: extra_ld_opts= [ "-Wl,-rpath,c:/Programme/haskell-jvm-bridge-0.3-RC1/lib/", "- L" ] ? Thanks Dmitri Pissarenko -- Dmitri Pissarenko Software Engineer http://dapissarenko.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Parse error in a package file
Dmitri Pissarenko <[EMAIL PROTECTED]> writes: > Hello! > > I'm building the haskell-jvm-bridge (http://sourceforge.net/projects/jvm- > bridge/). > > The final step of the building procedure is to install the package of haskell- > jvm-bridge. > > When I enter ghc-pkg -a -f javavm.ghc-pkg I'm getting the error > > javavm.ghc-pkg: parse error in package config file (snip) > Please tell me what's wrong with this package file. Looks like there are a bunch of mis-placed "-L"s in the file. Maybe they need to be quoted? peace, isaac ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe