I understand your point Ryan, but in that case, why didn't the error occur
when Resource and ResourceId were separated classes?
BTW, I assume for your Int instance of Resource, you meant:
instance Resource Int where
type IdOf *Int* = Int
type LocOf *Int* = String
type CfgOf *Int* = ()
On Tue, Nov 2, 2010 at 12:32 AM, Yves Parès limestr...@gmail.com wrote:
I understand your point Ryan, but in that case, why didn't the error occur
when Resource and ResourceId were separated classes?
Because there was only one retrieveLoc for a particular IdOf, even
if resources shared an IdOf.
Hi,
There's nothing wrong with your type families. The problem is that the compiler
doesn't know that the m and rsc of eval are the same as m and rsc of runLoader.
(Also you had a small bug in the type of eval)
You need the ScopedTypeVariables extension, with a forall on runLoader to tell
GHC
Yes, I did make a small mistake in the type of eval.
In fact, through the compiler messages, I guessed that it was a problem of
matching between the 'rsc' type variable of runLoader and the 'rsc' of eval.
I thought that this kind of matching was automatic in Haskell, well I was
wrong... Thanks !
Hi Yves,
On 11/01/2010 09:44 PM, Yves Parès wrote:
Yes, I did make a small mistake in the type of eval.
In fact, through the compiler messages, I guessed that it was a problem of
matching between the 'rsc' type variable of runLoader and the 'rsc' of eval.
I thought that this kind of matching
Just out of curiosity: Does it work if you omit eval's type signature?
In fact you can't omit it since EDSL is a GADT.
I don't know why there is this restriction, but it is written in
operational's documentation:
This one is easy:
-- | Class describing a resource of type @rsc@
class (Ord (IdOf rsc)) = Resource rsc where
type IdOf rsc
type LocOf rsc
type CfgOf rsc
retrieveLoc :: CfgOf rsc - IdOf rsc - LocOf rsc
load :: LocOf rsc - IO (Maybe rsc)
-- ^ Called when a resource needs to
Hello,
I'm trying to make a simple monad (built on operational's ProgramT) for
resource loading.
I have classes featuring type families :
{-# LANGUAGE TypeFamilies, FlexibleContexts, GADTs #-}
-- | A ResourceId is something that identifies a resource.
-- It should be unique for one resource,