Hi,
I have a daml file that use both TextMap and Map.
When using insert, I get an error that says insert can be in TextMap or in Map and that it can’t decide even though the type is Map Party MyData
Any idea?
Hi,
I have a daml file that use both TextMap and Map.
When using insert, I get an error that says insert can be in TextMap or in Map and that it can’t decide even though the type is Map Party MyData
Any idea?
You can either be explicit by using qualified imports
import DA.TextMap as TM
import DA.Next.Map as M
and then use M.insert
.
Or you hide the function from one of the imports:
import DA.TextMap hiding (insert, empty)
import DA.Next.Map
and then just use insert
and empty
as usual.
Or – third option – make one a qualified import:
import DA.TextMap qualified as TM
import DA.Next.Map
Now insert
refers to DA.Next.Map.insert
, and to use the TextMap
version you have to use TM.insert
.
Bit of a syntax quirk we inherited from Haskell, but worth pointing out the tradeoffs of each form.
import Lib
will import each symbol s
in Lib
as s
, as if they had been defined in the current module.
import qualified Lib
will import each symbol s
in Lib
as Lib.s
.
import qualified Lib as L
will import each symbol s
in Lib
as L.s
import Lib as L
will import each symbol s
in Lib
as both L.s
and s
. I personally recommend never using this one.
Finally, for each form, you can limit the set of imported symbols by either whitelisting:
import Lib (f, g)
or blacklisting:
import Lib hiding (f, g)
For your case, I would recommend importing both modules qualified. But then again, I’m a bit biased, as I tend to always import all my modules qualified.