Using Set: Hypergraph type

Eray Ozkural (exa) erayo@cs.bilkent.edu.tr
Tue, 4 Sep 2001 20:28:55 +0300


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi Dan,

Thanks for your help.

On Tuesday 04 September 2001 05:27 pm, Daan Leijen wrote:
> Unfortunately, you don't show the type error that
> was returned. 

It was a bit long. Anyway, here it is:

Hypergraph> elementOf (mkSet [1]) (hgraph [ [1,2], [1] ])

<no file>:0:
    No instance for `Ord (Set a)'
    arising from use of `hgraph' at <no file>:0
    In the second argument of `elementOf', namely
	`(hgraph [[1, 2], [1]])'
    in the definition of function `it':
	elementOf (mkSet [1]) (hgraph [[1, 2], [1]])

<no file>:0:
    Ambiguous type variable(s) `a' in the constraint `Ord a'
    arising from use of `hgraph' at <no file>:0
    In the second argument of `elementOf', namely
	`(hgraph [[1, 2], [1]])'
    in the definition of function `it':
	elementOf (mkSet [1]) (hgraph [[1, 2], [1]])

<no file>:0:
    Ambiguous type variable(s) `a' in the constraint `Num a'
    arising from the literal `1' at <no file>:0
    In the list element: 1
    In the list element: [1]

Okay, I guess I got it now. The (types of) elements of a Set ought to be 
instances of Ord. So I presume Edison supports only flat sets. So, this is 
not really a mathematical set, whichever set theory you take to be correct :)

I guess a roughly working and more-efficient-than-list set type would be very 
useful for mathematicians and computer scientists. And writing one turns out 
to be extremely difficult, which set theory should one take? :) I 
particularly like the hyperset formulation, but then implementing hypergraphs 
might be a little circular. :)) 

> However, I think that Hugs/GHCi
> is unable to figure out which numeric (Num a)
> instance you are using (Int,Integer, Double??).
> You can help the interpreter a little bit by
>
> providing a type annotation:
> > elementOf (mkSet [(1::Int)]) (hgraph [ [1,2], [1] ])
>
> or a constant with a type signature
>
> > list1 :: [Int]
> > list1  = [1]
> >
> > test =  elementOf (mkSet list1) (hgraph [ [1,2], [1] ])
>
Hypergraph> elementOf (mkSet [(1::Int)]) (hgraph [ [1,2], [1] ])

<no file>:0:
    No instance for `Ord (Set Int)'
    arising from use of `hgraph' at <no file>:0
    In the second argument of `elementOf', namely
	`(hgraph [[1, 2], [1]])'
    in the definition of function `it':
	elementOf (mkSet [(1 :: Int)]) (hgraph [[1, 2], [1]])

This does reduce the errors, but I guess this is just something that Edison 
is not up to (yet).

I'm afraid I'll have to mimic the common imperative hypergraph 
representation, which means some more work for me :)

Thanks,

- -- 
Eray Ozkural (exa) <erayo@cs.bilkent.edu.tr>
Comp. Sci. Dept., Bilkent University, Ankara
www: http://www.cs.bilkent.edu.tr/~erayo
GPG public key fingerprint: 360C 852F 88B0 A745 F31B  EA0F 7C07 AE16 874D 539C
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE7lQ9ZfAeuFodNU5wRAhuXAJ9WmGqXODtZO6oWSECAdD8ucwtwwACeJm6/
RKMKLPFWQDfKEhYHHN0f7TU=
=jwu8
-----END PGP SIGNATURE-----