Let's say I have the following code
module A where
x :: Int
x = 5
module Main where
import A
import Lib
main :: IO ()
main = print (x + y)
and in an external library
module Lib where
y :: Int
y = 10
All well and good, the library is at v0.1.0.0 and I include it with bounds mylib == 0.1.*
Now, the name x :: Int
is added to the export list of MyLib and a new release is out. It's version is v0.1.1.0, as suggested in the PVP flowchart:
In this case, only [...] functions [...] were added to the library's exported interface. No breakage [...] could result
How is this assertion correct? Surely my code no longer compiles. Since it doesn't know where to pull x
from.
You can prevent breakage with a defensive importing style. The Haskell wiki has an article about it:
We recommend to focus on the following two forms of import:
import qualified Very.Special.Module as VSM import Another.Important.Module (printf, (<|>), )
instead of
import Very.Special.Module import Another.Important.Module hiding (open, close, )
And the PVP rules are one of the reasons they advocate for the explicit style.