How to ensure optimization for large immutable vectors to be shared w.r.t. Referential Transparency

Viktor Dukhovni ietf-dane at dukhovni.org
Tue Apr 6 15:10:51 UTC 2021


On Tue, Apr 06, 2021 at 10:58:20PM +0800, YueCompl via ghc-devs wrote:

> On a second thought, maybe GHCi's silence is a bad thing here? Maybe
> it should complain loudly as GHC does?

No, GHCi is doing the expected thing.  Because GHCi's REPL sees one line
at a time, it is not generally possible for it to infer specific
monomorphic types on the spot, so GHCi infers the polymorphic type.

And as for the complaint, that was because I prepended: v `seq` ...
in which the type of `v` is ambiguous when polymorphic.  GHCi also
complains if you try that.

> λ> let v = VS.fromList [3,2,5] in isSameVector (SomeVector v) (SomeVector v)

One thing I'm not sure about, that perhaps someone else can shed light
on, is whether with optimisation one might expect the two (SomeVector v)
values to be subject to CSE, given that they both invoke `v` at the same
type.  Is there a non-default optimisation flag that makes CSE more
aggressive that would make that happen?

-- 
    Viktor.


More information about the ghc-devs mailing list