[GHC] #14254: The Binary instance for TypeRep smells a bit expensive
GHC
ghc-devs at haskell.org
Wed Oct 11 10:33:26 UTC 2017
#14254: The Binary instance for TypeRep smells a bit expensive
-------------------------------------+-------------------------------------
Reporter: dfeuer | Owner: (none)
Type: bug | Status: patch
Priority: normal | Milestone: 8.4.1
Component: Compiler | Version: 8.2.1
Resolution: | Keywords: Typeable
Operating System: Unknown/Multiple | Architecture:
Type of failure: Compile-time | Unknown/Multiple
performance bug | Test Case:
Blocked By: | Blocking:
Related Tickets: #14337 | Differential Rev(s): Phab:D3998,
Wiki Page: | Phab:D4082, Phab:D4085
-------------------------------------+-------------------------------------
Comment (by simonpj):
Re the loop, `Type` = `TYPE Lifted`. So the `TypeRep` for `Type` is a
`TrApp`, with a cached kind. So
{{{
TYPE Lifted :: TYPE Lifted
}}}
But that kind has a cached kind:
{{{
TYPE Lifted :: TYPE Lifted :: TYPE Lifted
}}}
and if the cache field is strict you build an infinite data structure.
The only way out of this I can see is to
* define a top level definition the `TypeRep` for `TYPE Lifted`
* in that definition, do not use `mkTrApp`; instead build an explicit loop
{{{
trTYPELifted = TrApp fpr trTYPE trLifted trTYPELifted
}}}
note that `trTYPELifted mentions itself directly.
* In `mkTrApp` spot that case, and return `trTYPELifted`.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14254#comment:14>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list