Skip to content

cabal init incorrectly writes non-ASCII file names in library:exposed-modules #6507

Open
@kartik-sabharwal

Description

Describe the bug
Consider a folder hierarchy that looks like

proglet/
|- Typeclass/
   |- Pokémon.hs

Running cabal init --interactive when the working directory is proglet generates the files necessary for cabal v2-build.

Running cabal v2-build, however, gives the unexpected error

Typeclass/Pokémon.hs:1:8: error:
    File name does not match module name:
    Saw: ‘Typeclass.Pokémon’
    Expected: ‘Typeclass.Pokémon’
  |
1 | module Typeclass.Pokémon where
  |        ^^^^^^^^^^^^^^^^^

To Reproduce

  1. Create folder proglet
  2. Create folder proglet/Typeclass
  3. Create file proglet/Typeclass/Pokémon.hs with content
module Typeclass.Pokémon where

x = 1
  1. Change the working directory to proglet
  2. Run cabal init --interactive and complete the prompts this way
  • Don't generate a "simple project with sensible defaults"
  • Build a library
  • Use any version of the Cabal specification
  • Any package name of your choosing
  • Any package version
  • Any license
  • Any author name
  • Any email
  • Any project URL
  • Any synopsis
  • Any category
  • No source directory
  • No test suite
  • Haskell2010
  • No "informative comments"
  1. Run cabal v2-build and observe the error

Expected behavior
I expected the build to succeed.

System information

  • Operating system: macOS 10.14
  • cabal version: 3.0.0.0
  • ghc version: 8.6.5

Additional context
It seems that the "e with acute accent" under "Saw" is the UTF-8 character U+00E9, while the "e with acute accent" under "Expected" is a combination of the normal letter "e" (U+0065) and some acute accent character.

Since the "e with acute accent" under "Expected" corresponds to the contents of the library:exposed-modules section of the .cabal file, I checked proglet.cabal (I have removed the comment lines below).

cabal-version:       2.4

name:                proglet
version:             0.1.0.0
license:             BSD-3-Clause
license-file:        LICENSE
author:              Fyrbll
maintainer:          unnecessary
extra-source-files:  CHANGELOG.md

library
  exposed-modules:     Typeclass.Pokémon
  build-depends:       base ^>=4.12.0.0
  default-language:    Haskell2010

I changed Typeclass.Pokémon in the file above to Typeclass.Pokémon, where the latter actually uses U+00E9, and then cabal build worked painlessly.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions