implicit parameters
Jeffrey R Lewis
jeff@galois.com
Thu, 17 Apr 2003 11:08:35 -0700
On Thursday, April 17, 2003, at 10:35 AM, Dean Herington wrote:
> There's apparently something very basic that I don't understand about
> implicit parameters. In the following program, compilation fails if
> either of the type declarations is omitted. What is "implicit" about
> implicit parameters, then?
>
> {-# OPTIONS -fglasgow-exts #-}
>
> main = print f1
>
> f1 = let ?f = \ x -> x ++ x in f2
>
> f2 :: (?f :: String -> String) => String
> f2 = f3
>
> f3 :: (?f :: String -> String) => String
> f3 = ?f "x"
>
>
The detail that you are missing is that implicit parameters are subject
to the "monomorphism restriction". If f2 and f3 were functions, you
wouldn't get errors when omitting signatures.
And yes, the decision to have them obey the monomorphism restriction is
questionable, but then so is the monomorphism restriction ;-)
--Jeff