Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what is parse error: naked expression at top level?

Tags:

syntax

haskell

I was trying to get the length of each element, given a nested list; and I also I want to get rid of the repeated length.

For example, a nested list [[1],[1,2],[4..5]] should give me [1,2].

I can do it in the interactive by nub (map length [[1],[1,2],[4..5]]). But if I write a file with the following code:

Import Data.List
getLen :: [[a]] ->[Int]
getLen xs = nub (map length xs)

I got the error saying:

"Parse error: naked expression at top level"

What does this error mean and how can I fix this?

like image 837
vwendy Avatar asked Dec 09 '25 10:12

vwendy


1 Answers

Simple change: it's import not Import.

like image 55
augustss Avatar answered Dec 12 '25 07:12

augustss



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!