Making implicit parameters explicit
Tomasz Zielonka
t.zielonka at students.mimuw.edu.pl
Thu Nov 6 22:02:26 EST 2003
On Wed, Nov 05, 2003 at 09:13:12PM +0100, Stefan Reich wrote:
> Hi,
>
> I discovered implicit parameters today and I'm very excited about them
> because they allow to express certain code constructs more elegantly.
> However, I stumbled upon a problem. Suppose I have these definitions
> (the definition of Request is irrelevant):
>
> type Controller = (?req :: Request) => String
>
> controller1 :: Controller
> controller2 :: Controller
>
> controllerList = [controller1, controller2]
>
> GHC complains with:
>
> Unbound implicit parameter (?req :: Request)
> arising from use of `controller1'
> In the list element: controller1
> In the definition of `controllerList':
> controllerList = [controller1, controller2]
You have just been bitten by monomorphism restriction. Write a type
signature for controllerList and it should work:
controllerList :: (?req :: Request) => [String]
Best regards,
Tom
--
.signature: Too many levels of symbolic links
More information about the Glasgow-haskell-users
mailing list