haskell / haskell/haskell-mode

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

Open
#1,888 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Emacs Lisp
Stars
1.4k
Forks
354
Avg merge
5d 10h
Merged PRs (30d)
2

Description

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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.