while trying to understand the usage of the function withClockResetEnable in Clash.Prelude, I found the signature of this function like this:
withClockResetEnable
:: forall dom r. KnownDomain dom
=> Clock dom
-> Reset dom
-> Enable dom
-> (HiddenClockResetEnable dom => r)
-> r
The thing really cause my confusion is this part
-> (HiddenClockResetEnable dom => r)
which has a comment below: The function with a hidden Clock, hidden Reset, and hidden Enable argument
My confusion is, my limited knowledge tell me, since there is a =>, this line is maybe indicated a type constraint, like the polymorphic type r should have an instance of HiddenClockResetEnable dom, which still makes no sense to me, and I cannot link this line to the comment at all.
This is using the
ImplicitParamslanguage option.HiddenClockResetEnableis defined as:Each of the parts such as
HiddenClockis defined like this:We have
KnownDomainin the constraints onwithClockResetEnable. So what isHidden?The
IPclass is what theImplicitParamssyntax desugars to. So the original signature means:In other words, if you call
withClockResetEnable c r e f, andfis some computation that takes these parameters implicitly, thenwithClockResetEnablewill callfwith those arguments for the implicit parameters: