Question about HsWrapper for constructors

Hi all, I've tried a development snapshot of GHC's master branch from the beginning of this month and I am curious about the reason for a specific change. I noticed that a simple program like idNil :: [a] -> [a] idNil [] = [] is internally represented (after type checking) as: AbsBinds [] [] {Exports: [idNil <= idNil2] Exported types: idNil :: forall a. [a] -> [a] Binds: idNil2 [] = (/\(@a2). [] @a2) @a Can someone point me to a reason why the right side of idNil2 is not represented as [] @ a, like it was in GHC 8.10.1? I have not tried it with GHC 9.0. It is interesting to have a type lambda that is immediately followed by a type application. Thanks, Kai

Hi Kai,
This was changed with linear types.
In Core, the constructor Just has now the linear type forall a. a %1 -> Maybe a.
For backwards compatibility, every occurrence of Just is eta-expanded
to \(@a # m) (x :: a) -> Just @a x, so that it can be used in a
non-linear context.
In the case of [], this transformation adds an extra type parameter, which
doesn't change much.
The details are in return_data_con and in Note [Linear fields generalization]
in Tc/Gen/Head.hs.
Best,
Krzysztof
On Wed, Nov 18, 2020 at 5:01 PM Kai-Oliver Prott
Hi all,
I've tried a development snapshot of GHC's master branch from the beginning of this month and I am curious about the reason for a specific change. I noticed that a simple program like
idNil :: [a] -> [a] idNil [] = []
is internally represented (after type checking) as:
AbsBinds [] [] {Exports: [idNil <= idNil2] Exported types: idNil :: forall a. [a] -> [a] Binds: idNil2 [] = (/\(@a2). [] @a2) @a
Can someone point me to a reason why the right side of idNil2 is not represented as [] @ a, like it was in GHC 8.10.1? I have not tried it with GHC 9.0. It is interesting to have a type lambda that is immediately followed by a type application.
Thanks,
Kai
_______________________________________________ ghc-devs mailing list ghc-devs@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs
participants (2)
-
Kai-Oliver Prott
-
Krzysztof Gogolewski