Preventing import of `DA.Internal`
- LucianoOP 1
Continuing the discussion from How to qualify names in export list?:
Following @bernhard 's suggestion, I have used
{-# LANGAUGE NoImplicitPrelude #-}to try and hide some standard functions; however, I’m still getting errors such as:/home/luciano/src/da-marketplace/contingent-claims/daml/ContingentClaims/Valuation.daml|26 col 25| typecheck:Error:/home/luciano/src/da-marketplace/contingent-claims/daml/ContingentClaims/Valuation.daml:26:25: error: Ambiguous occurrence ‘negate’ It could refer to either ‘DA.Internal.RebindableSyntax.negate’, imported from ‘DA.Internal.RebindableSyntax’ (and originally defined in ‘GHC.Num’) or ‘ContingentClaims.Math.Ring.negate’, imported from ‘ContingentClaims.Math.Ring’ at /home/luciano/src/da-marketplace/contingent-claims/daml/ContingentClaims/Valuation.daml:7:1-33 (and originally defined at /home/luciano/src/da-marketplace/contingent-claims/daml/ContingentClaims/Math/Ring.daml:21:1-6)Is this a bug?
Looking at the source code, I can see that
Preludere-exports some of theseDA.Internalfunctions.
What confuses me is that it’s impossible to explicitly importDA.Internal(it throws an error saying this is not allowed), so I’m baffled why these are even in scope. - cocreature 1
The Daml compiler inserts 3 imports automatically which are used for desugaring of templates, records and some other stuff. Those imports are
import qualified GHC.Typesimport qualified DA.Internal.Desugarimport DA.Internal.RebindableSyntax
The latter is what makes some Haskell syntax contracts (e.g. string literals) work in Daml. There isn’t really any way to disable that import since it is crucial to Daml working as intended.
I think it’s also worth pointing out that all of this is an implementation detail and not something you can rely on.
- Luciano
Is there any other way I can overload the
pureoperator?This is something that’s been nagging me for ages now, and it would simplify my code considerably.
- cocreature
What’s stopping you from using another name than
pure? - Luciano
Nothing; the meaning of
purehere is that of anApplicative; that’s why I want to use this term. But there’s no corresponding<*>operator, so I can’t implement a typeclass instance. - cocreature
In Haskell,
pointis commonly used for things that can implement something likepurebut no(<*>)