[Haskell-cafe] Re: Does anybody dislike implicit params as much asI do?

Ashley Yakeley ashley at semantic.org
Sat Mar 14 20:44:23 EDT 2009


Sittampalam, Ganesh wrote:
> I think they have a useful place in propagating semi-global
> configuration information without imposing huge syntactic overhead.

Right, for instance,

   type MyMonad a = (?env :: Env) => IO a

No lift needed!

I was hoping to use IPs to do OO-style implicit type conversion from a 
"derived" type to "base" type. For instance:

   type Base = forall a. ((?f1 :: Int) => a) -> a

   field1 :: Base -> Int
   field1 b = b ?f1

   type Derived = forall a. ((?f1 :: Int, ?f2 :: String) => a) -> a

   d :: Derived
   d x = let {?f1 = 3;?f2 = "Hello"} in x

   f1d :: Int
   f1d = field1 d

Annoyingly, GHC objects to the "field1 d" application.

-- 
Ashley Yakeley


More information about the Haskell-Cafe mailing list