Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6542563
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:14:34+00:00 2026-05-25T11:14:34+00:00

Given the following function, I receive a parse error from GHC. has_empty_string :: [String]

  • 0

Given the following function, I receive a parse error from GHC.

has_empty_string :: [String] -> Bool
has_empty_string col =
  not foldl (\acc now -> if and [acc == True, now == ""] then False else True) True col

I’ve checked a variety of tutorials and I don’t see the error.

What is more confusing is that GHC takes it, when I prepend let to the definition.


Rewritten to use any_null.

I have a suspicion that the error is actually elsewhere…

module Main where
import System.Cmd
import System.Directory
import System.Environment
import System.IO
import System.Process
import Text.Regex.Posix
import Data.CSV.Enumerator
import Data.Spreadsheet

import Data.Char (isSpace)

--------------------------------------------------
slurp :: String -> IO String
slurp path = do
  withFile path ReadMode (\handle -> do
                             contents <- hGetContents handle
                             last contents `seq` return contents )

--------------------------------------------------
has_empty_string :: [String] -> Bool
has_empty_string col =
  any null

main :: IO ()
main = do
  [filename] <- getArgs
  raw_data <- slurp filename
  let csv_data = fromString '"' ',' raw_data
  -- checking to see if the 5th column is an empty string
  content_hashes = get_hashrow csv_data
                   where get_hashrow = map (\row -> row !! 5) csv_data
  is_good_csv = has_empty_hash content_hashes
  putStrLn $ show csv_data
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T11:14:35+00:00Added an answer on May 25, 2026 at 11:14 am

    When I try to compile your code with ghc I get a type error, not a parse error. That error is because you’re trying to call not with foldl as its first argument and (\ acc now -> ...) as the second argument. You need to add a $ after not or wrap the call to foldl in parentheses.

    You probably got the parser error you mentioned in ghci. In ghci you’re not allowed to write definitions the way you would in a file. You’re only allowed to enter expressions (which will then be evaluated and the result printed – or executed if it’s an IO action) or anything you could write inside an IO do block (i.e. foo <- bar and let foo = bar).

    So in ghci you can define variables and functions only by using let and you can’t define types at all.

    The parse error you get is actually caused by main where you try to define local variables without let. Just add ´letbeforecontent_hashes = …andis_good_csv = …` and the parse error will disappear.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given the following: #light //any function returning bool * 'a let foo = let
Given the following Flash method: function sendToJava(name:String, ... args) { ExternalInterface.call(sendCommand, name, args); }
Given the following function: def foo(a, b, c): pass How would one obtain a
Given the following C function in a DLL: char * GetDir(char* path ); How
Given the following javascript: function foo(selectControl) { ... } and the following html: <select
Given the following Delphil DLL declaration function csd_HandleData(aBuf: PChar; aLen: integer): integer; stdcall; what
Given the following code,the hover function works correctly, but when clicked, loses the clicked_no_event_box
Given the following javascript (jquery) $(#username).keyup(function () { selected.username = $(#username).val(); var url =
Given the following code snippet: $i= 11; function get_num() { global $i; return (--$i
Given the following jquery code.. jQuery.fn.sliding = function () { return this.each(function () {

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.