A functional dependency seems to allow me to express my rather strange
requirement.
class Person i n | i -> n where
pid :: i
name :: i -> n
instance Person Int String where
pid = 1
name(1) = "john"
-- name(pid::Int) will produce john
Thanks for your help
Pat
On 17/01/2011 14:07, Patrick Browne wrote:
> On 17/01/2011 13:04, Ketil Malde wrote:
>>> So other PERSONs would have different types, say:
>
> I think the problem is there is just one constant p1 in the class and
> there needs to be multiple constants in the implementation (one for each
> person). It seems difficult to specify this using type classes So, some
> data declaration as you suggest will probably be needed.
>
> Thanks,
> Pat
>
>
>
> This message has been scanned for content and viruses by the DIT Information
> Services E-Mail Scanning Service, and is believed to be clean.
> http://www.dit.ie
>
> _______________________________________________
> Haskell-Cafe mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/haskell-cafe
This message has been scanned for content and viruses by the DIT Information
Services E-Mail Scanning Service, and is believed to be clean. http://www.dit.ie
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe