From: Bjorn B. <bri...@cs...> - 2006-08-06 16:31:08
|
On Aug 6, 2006, at 5:15 PM, Marc Weber wrote: > eg mysqlConnect is of type: > mysqlConnect :: MonadIO m =3D> MySQLOptions -> (Database -> m a) -> m = a > > Typical usage looks like this, doesn't it? > > > doSomething :: MonadIO m =3D> (Database -> m a) -> m a -> IO () = -- << > main=3Ddo > con <- mysqlConnect Options > doSomething con .. > > Wouln't it be mucht clearer to use another typedef to write =20 > something like this ? > > > newtype CConnection :: MonadIO m =3D> (Database -> m a) -> m a > doSomething :: CConnection -> IO () -- << much shorter and = clearer > main=3Ddo > con <- mysqlConnect Options > doSomething con .. > > The first C migt indicate that it's a "connected" connection =20 > (parameters have already been applied).. > Or does this already exist? > > I'd like to provide a patch if you consider it useful > > Greetings > Marc Weber Hi Marc, I'm not sure that I completely understand your example. I think that =20 there is something wrong with the types. Here's how I think a typical application looks with the current types: options :: MysqlOptions options =3D ... doSomething :: Database -> IO () doSomething db =3D ... main :: IO () main =3D mysqlConnect options doSomething I probably misunderstood what you want to do though. /Bj=F6rn |