On my question >> Here is a small awkwardness with naming. ... >> Defining the operation of the set cardinality, we put naturally >> that it may return >> FiniteCard n, n >= 0 :: Integer >> InfiniteCard, >> UnknownCard >> But in this case, - as in many others, - there are several values >> in result which clearly cannot be returned by the operation. >> Thus, in the example, we can put >> class Set where card :: a -> Integer --has a sample argument >> ... >> and let card to return -1 for InfiniteCard, -2 for UnknownCard >> ... Fergus Henderson <[EMAIL PROTECTED]> writes > I advice just using a discriminated union -- this is exactly the > sort of situation they're designed for. Using a discriminated union > leads to clearer programs, IMHO, and reduces that danger of > accidentally forgetting one of the alternatives. > > data Card = FiniteCard Natural > | InfiniteCard, > | UnknownCard > > type Natural = Integer -- used for integers whose value should be >= 0 Thank you. This was the initial intention. Many data constructors have to be introduced in this way. For, not only `card' needs the value type extension. The idea was to reduce this - in the case when the regular values do not fill all the type. Though, i have, probably, to return to the solution you advise. ------------------ Sergey Mechveliani [EMAIL PROTECTED]
