Function: haskell-string-literal-decode

haskell-string-literal-decode is a natively compiled function defined in haskell-string.el.

Signature

(haskell-string-literal-decode ESTR &optional NO-QUOTES)

Documentation

Decode a Haskell string-literal.

If NO-QUOTES is nil, ESTR must be surrounded by quotes.

This is the dual operation to haskell-string-literal-encode.

Source Code

;; Defined in /nix/store/9lz2mhw95f9fqxr9mnq46k3f6qz3aq83-emacs-packages-deps/share/emacs/site-lisp/elpa/haskell-mode-20260904.1042/haskell-string.el
(defun haskell-string-literal-decode (estr &optional no-quotes)
  "Decode a Haskell string-literal.
If NO-QUOTES is nil, ESTR must be surrounded by quotes.

This is the dual operation to `haskell-string-literal-encode'."
  (if (and (not no-quotes)
           (string-match-p "\\`\"[^\\\"[:cntrl:]]*\"\\'" estr))
      (substring estr 1 -1) ;; optimized fast-path for trivial strings
    (let ((s (if no-quotes ;; else: do general decoding
                 estr
               (if (string-match-p "\\`\".*\"\\'" estr)
                   (substring estr 1 -1)
                 (error "String literal must be delimited by quotes"))))
          (case-fold-search nil))
      (replace-regexp-in-string haskell-string-literal-escapes-regexp #'haskell-string-literal-decode1 s t t))))