Haskell parser error in where clause

392

Your indentation was wrong and i think you can only have one where in there (i could be very well wrong. I'm not a haskell guy). There was also a argument missing for the call to rev (an empty list):

palindrome :: [a] -> [a]
palindrome xs = con xs rs
    where con a b = rev (rev a []) b
          rs = rev xs []                       -- here
          rev [] rs = rs
          rev (x:xs) rs = rev xs (x:rs)

main = print (palindrome "hello")

Prints out:

"helloolleh"

I'm going to try to understand it now. Anyway, have fun!

Edit: Makes perfect sense to me now. I think that's the right version. For Haskell indentation rules, read Haskell Indentation

Share:
392
user401445
Author by

user401445

Updated on June 13, 2022

Comments

  • user401445
    user401445 almost 2 years

    I'm using EMR to move a folder from local file system to S3 in Spark using fs.moveFromLocalFile API. Everything works fine except a 0-byte file created by EMRFS with name _$folder$ for EVERY folder that is uploaded.

    Is there any way to move folders without this dummy file creation for every folder? (other than manually deleting this file). Also, why is this dummy file created? I'm currently using s3:// protocol recommended by EMR team.

  • Shruti Singh
    Shruti Singh over 15 years
    You are right, rs must start in same column as con in previous line. It is weird rule.
  • Svante
    Svante over 15 years
    Not weird: same syntactic level -> same indentation
  • Cubic
    Cubic about 12 years
    I thought (++) was defined as (++) = flip $ foldr (:) - that's how I would've written it anyways.
  • stevel
    stevel over 7 years
    it's trickier than you think. We need to (a) make sure that you can't mkdir under a file and (b) that empty directories exist when you do an ls. It's there in the expected semantics of an fs that mkdir path; ls path returns something successful. The FS clients do delete the marker files when things underneath are created