How to qualify names in export list?

I have the following module definition:

module Observation (Observation, pure) where

import Prelude hiding (pure)

pure = ...

This won’t compile; it complains about pure being ambiguous, as it appears in the Prelude also.

Is there any way I can explicitly refer to the current module to include this in the exports lists?

I tried moving the import up, but it appears the first directive expected is module.

2 Likes

Your problem is that Prelude is always imported in full. import Prelude hiding (pure) doesn’t hide the implicit import of Prelude.

You can use the language extension NoImplicitPrelude to remove the implicit import, which should make your code compile. But think carefully about doing so. Messing with Prelude makes your code inherently harder to read for anyone else.

Note also that language extensions like this are not really “supported” by DAML. They work by virtue of the GHC compiler frontend, which the DAML compiler uses. We don’t test that they work well, so code using such extensions may break without warning.

2 Likes