[GHC] #14610: newtype wrapping of a monadic stack kills performance
GHC
ghc-devs at haskell.org
Tue Jan 2 15:20:50 UTC 2018
#14610: newtype wrapping of a monadic stack kills performance
-------------------------------------+-------------------------------------
Reporter: mrkkrp | Owner: (none)
Type: bug | Status: new
Priority: normal | Milestone: 8.6.1
Component: Compiler | Version: 8.2.2
Resolution: | Keywords: JoinPoints
Operating System: Unknown/Multiple | Architecture:
Type of failure: Runtime | Unknown/Multiple
performance bug | Test Case:
Blocked By: | Blocking:
Related Tickets: #14620 | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by nomeata):
Here is an idea. Consider a recursive function `foo` with type
{{{
foo :: forall t, a -> r t
foo @t a = E[foo @t2 x `cast` co)] -- E[_] is tail call context, and the
cast prevents join-point-hood
}}}
But we can transform this into a form that is allowed by now, just by
introducing casts:
{{{
foo :: forall t, a -> r t
foo @t a = go @t a refl
where
go :: forall t', a -> (r t ~ r t') -> r t
go @t' a = E[go @t'2 co]
}}}
Note that now the return type does no longer depend on the arguments of
`go`, so it is a join point.
This transformation smells like a worker-wrapper transformation, but I am
not sure.
Anyways, I am not arguing that we should do this transformation in GHC,
but do it in the proofs so that we can simply happily remove the
restriction in `isValidJoinPointType`.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14610#comment:18>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list