10Pines / pdepreludat

BSD 3-Clause "New" or "Revised" License
24 stars 2 forks source link

Set other modules to none for library #26

Closed JuanFdS closed 3 years ago

JuanFdS commented 3 years ago

The Problem

proyecto-test is a project created by following https://github.com/10Pines/pdepreludat#preparar-proyecto : stack new proyecto-test https://github.com/10Pines/pdepreludat/releases/download/2.0.5/pdepreludat.hsfiles

Notice how it loads a module called Paths_proyecto_test and how asking the type to a number shows Num p => p (prelude's behaviour) instead of Number (pdepreludat's behaviour) image

Why this happened

It seems that in one of the latest versions of hpack, when generating the cabal file from the package.yaml a module called Path_proyectname was being added to other-modules. That module is loaded when you run stack ghci at the root of the project.

It's usually not problematic but in our case it is. This is because that module is importing the Prelude and we don't want that to happen because we are already providing an alternative Prelude.

Solution

We set other-modules to [] instead of the recommended solution because that solution implied writing the project name in the package yaml with _ instead of - (so if the project name was test-project it'd have to be written as test_project in the package.yaml). And that was kind of a pain to add to the template.

image

What can I do if I already have a project set up and it has this problem?

If you created a PdePreludat project before this fix, what you need to do is: