When an input longer than 255 characters is typed into comint (or
shell) an EOT character (ascii 4, ^D) is inserted into the string.
This can cause an error depending how the sub process handles these
extra characters.  For example, GHC doesn't like it when an EOT
appears inside of a string:

 ghci
 > Prelude> putStrLn "<a 241 character string>"
works fine, but
 > Prelude> putStrLn "<a 242 character string>"
<interactive>:1:255: lexical error at character '\EOT'

I inserted a function to break up the input into comint-send-string to work around the problem:

(require 'comint)

(defun comint-send-string (process string)
  "Like `process-send-string', but also does extra bookkeeping for Comint mode."
  (if process
      (with-current-buffer (if (processp process)
                   (process-buffer process)
                 (get-buffer process))
    (comint-snapshot-last-prompt))
    (comint-snapshot-last-prompt))
  (my-process-send-string process string))

;; Break up the string so that we don't get EOT characters in our input stream.
(defun my-process-send-string (process string)
  (if (> (length string) 200)
      (progn (process-send-string process (substring string 0 200)) (my-process-send-string process (substring string 200)))
    (process-send-string process string)))