I'm curious about the objections to implicit parameters discussed in the Functional Pearl: Implicit Configurations article by Kiselyov and Shan.
It is not sound to inline code (β-reduce) in the presence of implicit parameters.
Really? I'd expect that GHC should inline into the same scope as the passed implicit parameter, no?
I believe I understand their objection that :
A term’s behavior can change if its signature is added, removed, or changed.
GHC's user documentation explains that programers must take care around polymorphic recursion and monomorphism restriction. Is this somehow what they mean by a problem for inlining?
I presume this polymorphic recursion example covers what they mean by "generalizing over implicit parameters" as well? Anything else?
Is the ReifiesStorable
type class from Data.Reflection really a sensible solution to these difficulties? It seemingly deserializes the entire implicit data structure every time it's accessed, which sounds be disastrous for performance. We might for-example want our implicit information to be Cayley table or character table that occupies a gig of ram and must be access during millions of algebraic operations.
Is there perhaps some better solution that employs implicit parameters, or another technique the compiler can easily optimize, behind the scenes, while still guaranteeing more via the type system using state threads or whatever?