Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the "coverage condition"?

The source for the State transformer in mtl states:

-- ---------------------------------------------------------------------------
-- Instances for other mtl transformers
--
-- All of these instances need UndecidableInstances,
-- because they do not satisfy the coverage condition.

What is the "coverage condition"? All I can tell is that it has something to do with MTPCs and fundeps.

like image 627
Dan Burton Avatar asked Aug 14 '12 19:08

Dan Burton


People also ask

What is condition coverage?

Definition(s): The percentage of conditions within decision expressions that have been evaluated to both true and false.

What is Decision coverage The coverage of condition outcomes?

The percentage of all condition outcomes and decision outcomes that have been exercised by a test suite. 100% decision condition coverage implies both 100% condition coverage and 100% decision coverage.

What is the difference between condition coverage and Decision coverage?

With Condition/Decision coverage the possible outcomes of each condition and of the decision are tested at least once. This implies both Condition coverage and Decision coverage. In other words we cover that all conditions are one time TRUE and one time FALSE and we cover one time the THEN and one time the ELSE.

What is compound condition coverage?

Multiple condition coverage: A multiple (or compound) condition is one of all the available cases for the || and && logical operator compositions, whenever it appears in a C function.


1 Answers

Section 7.6.3.2 of the GHC manual tells us what the coverage condition is:

The Coverage Condition. For each functional dependency, tvsleft -> tvsright, of the class, every type variable in S(tvsright) must appear in S(tvsleft), where S is the substitution mapping each type variable in the class declaration to the corresponding type in the instance declaration.

In plain English, this means that if you have a type class with fundeps, for example:

class Convert a b | a -> b where
  convert :: a -> b

you can define the following instances:

instance Convert String String   -- no type variables
instance Convert [a]    [a]      -- type var a present on both sides
instance Convert (a,b)  a        -- a on the right => a on the left

but not the following instances:

instance Convert String a        -- a only present on the right
instance Convert a      (a,b)    -- b only present on the right
like image 122
opqdonut Avatar answered Sep 24 '22 06:09

opqdonut