[Haskell-cafe] Re: Foralls in records

2007-03-15 Thread Adde
Thanks! Serious food for thought. Ten years of object oriented brainwashing to undo :) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: [Haskell-cafe] Re: Foralls in records

2007-03-14 Thread Matthew Brecknell
Adde: > Thanks, using pattern matching to avoid mentioning the type didn't even > cross > my mind. > You are correct in assuming that I thought I could get away > with "getConnection :: Connection c => Transaction c". To be honest, I > still > don't understand why it's too polymorphic. To me it

[Haskell-cafe] Re: Foralls in records

2007-03-14 Thread Adde
Chris Kuklewicz list.mightyreason.com> writes: > Searching the haskell wiki for MonadIO gives several examples. > > http://haskell.org/haskellwiki/New_monads/MonadExit > > > instance MonadIO m => MonadIO (ExitT e m) where > > liftIO = lift . liftIO > > Where you can see you are just delegati

[Haskell-cafe] Re: Foralls in records

2007-03-14 Thread apfelmus
Adde wrote: >> Do you want to mix differently typed Connections inside a single >> transaction? It looks like you don't, so you may well leave out >> existential types altogether and simply parametrize the Transaction >> monad on the type of the connection it uses. >> >> data Connection c => Tran

[Haskell-cafe] Re: Foralls in records

2007-03-14 Thread Adde
> Do you want to mix differently typed Connections inside a single > transaction? It looks like you don't, so you may well leave out > existential types altogether and simply parametrize the Transaction > monad on the type of the connection it uses. > > data Connection c => TransactionState c =

[Haskell-cafe] Re: Foralls in records

2007-03-14 Thread Adde
Matthew Brecknell brecknell.org> writes: > Since the concrete type has been forgotten, there's no way to get it > back. You can't write a function that exposes the forgotten type, so > getConnection is basically a lost cause. When you write "getConnection > :: Transaction c", you are saying that

Re: [Haskell-cafe] Re: Foralls in records

2007-03-14 Thread Chris Kuklewicz
> I can't seem to find any examples of how to actually implement liftIO for a > monad. Any ideas/pointers? > Searching the haskell wiki for MonadIO gives several examples. http://haskell.org/haskellwiki/New_monads/MonadExit > instance MonadIO m => MonadIO (ExitT e m) where > liftIO = lift .

[Haskell-cafe] Re: Foralls in records

2007-03-14 Thread Adde
Martin Huschenbett gmx.org> writes: > > Hi, > > instead of writing a function getTransaction that retrieves the > connection you could write a function withConnection that doesn't return > the connection itself but performs an operation on the connection: > > withConnection :: > (foral

[Haskell-cafe] Re: Foralls in records

2007-03-14 Thread Martin Huschenbett
Hi, instead of writing a function getTransaction that retrieves the connection you could write a function withConnection that doesn't return the connection itself but performs an operation on the connection: withConnection :: (forall c. Connection c => c -> Transaction a) -> Transacti

[Haskell-cafe] Re: Foralls in records

2007-03-14 Thread apfelmus
Adde wrote: > I'm experimenting with implementing database transactions as monads but I'm > getting stuck on how to store a generic connection (only constrained by a > typeclass) inside the transaction. The reason I'm doing it this way is that > the connection could be a different kind of struct