Dominique,
That is exactly the information that I required.
Thank you very much,
Pat
On 23/07/12, Dominique Devriese <dominique.devri...@cs.kuleuven.be> wrote:
That is exactly the information that I required.
Thank you very much,
Pat
On 23/07/12, Dominique Devriese <dominique.devri...@cs.kuleuven.be> wrote:
Patrick,
> -- Class with functional dependency
> class QUEUE_SPEC_CLASS2 a q | q -> a where
> newC2 :: q a -- ??
> sizeC2 :: q a -> Int
> restC2 :: q a -> Maybe (q a)
> insertC2 :: q a -> a -> q a
The above is a reasonable type class definition for what you seem to intend.
> -- Without committing to some concrete representation such as list I do not know how to specify constructor for insertC2 ?? = ??
> insertC2 newC2 a = newC2 -- wrong
> isEmptyC2 :: q a -> Bool
> isEmptyC2 newC2 = True
> -- isEmptyC2 (insertC2 newC2 a) = False wrong
Correct me if I'm wrong, but what I understand you want to do here is
specify axioms on the behaviour of the above interface methods,
similar to how the well-known |Monad| class specifies for example "m
>>= return === m". You seem to want for example an axiom saying
isEmptyC2 newC2 === True
and similar for possible other equations. With such axioms you don't
need access to actual constructors and you don't want access to them
because concrete implementations may use a different representation
that does not use such constructors. Anyway, in current Haskell, such
type class axioms can not be formally specified or proven but they are
typically formulated as part of the documentation of a type class and
implementations of the type class are required to satisfy them but
this is not automatically verified.
Dominique
Tá an teachtaireacht seo scanta ó thaobh ábhar agus víreas ag Seirbhís Scanta Ríomhphost de chuid Seirbhísí Faisnéise, ITBÁC agus meastar í a bheith slán. http://www.dit.ie
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 Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe