Skip to content

cabal repl load modules (C-c C-L) with -Wx-partial wants to add {-# LANGUAGE Data #-} for every occurrence of head and tail #1888

@amcphail

Description

@amcphail

When loading a file in emacs, every occurrence of the functions head and tail trigger a question in the command buffer to add {-# LANGUAGE Data #-} to the top of the source file. This is triggered by the warning [-Wx-partial]

module Tmp where

test :: [Int] -> String
test [] = "empty"
test xs = show $ head xs
/src/Tmp.hs:5:18-21: warning: [GHC-63394] [-Wx-partial] …
    In the use of ‘head’
    (imported from Prelude, but defined in GHC.List):
    "This is a partial function, it throws an error on empty lists. Use pattern matching or Data.List.uncons instead. Consider refactoring to use Data.List.NonEmpty."
  |
src/Tmp.hs:5:18-21: warning: [GHC-63394] [-Wx-partial] …
    In the use of ‘head’
    (imported from Prelude, but defined in GHC.List):
    "This is a partial function, it throws an error on empty lists. Use pattern matching or Data.List.uncons instead. Consider refactoring to use Data.List.NonEmpty."

|

ghc --version
The Glorious Glasgow Haskell Compilation System, version 9.8.2

$ cabal --version
cabal-install version 3.16.1.0
compiled using version 3.16.1.0 of the Cabal library (in-tree)

$ emacs --version
GNU Emacs 28.2
Copyright (C) 2022 Free Software Foundation, Inc.
GNU Emacs comes with ABSOLUTELY NO WARRANTY.
You may redistribute copies of GNU Emacs
under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING.

haskell-mode version is latest stable from melpa

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions