Hi oleg,

On 4/9/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:

Alfonso Acosta wrote:

I have a type problem in my code which I dont know how to solve

> data HDSignal a = HDSignal
> class HDPrimType a where
> class PortIndex a where
>
> class SourcePort s where
>  -- Plug an external signal to the port
>  plugSig  :: (HDPrimType a, PortIndex ix) =>ix -> s  ->(HDSignal a -> b) -> b
>
> class DestPort d where
>  -- Supply a signal to the port
>  supplySig  :: (PortIndex ix, HDPrimType a) => HDSignal a -> ix -> d -> d
>
>
> -- Connect providing indexes
> connectIx :: (SourcePort s, PortIndex six, DestPort d, PortIndex dix) =>
>              six -> s -> dix -> d -> d
> connectIx six s dix d = plugSig six s $ (push2 supplySig) dix d

I'm afraid the example may be a bit too simplified. The first
question: what is the role of the |HDPrimType a| constraint in plugSig
and supplySig? Do the implementations of those functions invoke some
methods of the class HDPrimType?

Yes, I added the |HDPrimType a| constraint beacuse I realized I'm
forced to call a function from that class withoin supplySig . Actually
all the code was working smothly before adding the constraint which
has been te cause of my problem.

Or the |HDPrimType a| constraint is
just to declare that the parameter |a| of HDSignal is a member of
HDPrimType?

Unfortunately not


If plugSig and supplySig do use the methods of HDPrimType, one could
use existentials:

I tried the existential approach when it was previously suggested by
Chris, but the problem is that, for some Source instances calling
methods from HDPrimType within supplySig is not enough. Thus, it
doesn't work with existentials due to their limitations.

I'm definitively stuck wit this problem :S

Cheers,

Fons
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to