Attached file `CatQC.hs`

($1405).

Source code demonstrating the issue

In the code below, the return value of `forkIO`

is ignored. The compiler does not warn about this. When I disable the `ApplicativeDo`

extension, the warning appears as expected.

```
{-# OPTIONS_GHC -Wall #-}
{-# LANGUAGE ApplicativeDo #-}
module Example (main) where
import Control.Concurrent
main :: IO ()
main = do x <- return ()
forkIO (putStrLn "hello")
putStrLn $ "world" ++ show x
```

For the record: I have a working work-around using `Data.Constraint`

. The `functor`

class then reads

```
-- | A functor
class (Category (Dom f), Category (Cod f)) => Functor f where
-- | Prove that this functor maps from its domain to its codomain
proveFunctor :: Ok (Dom f) a => Ok (Dom f) a :- Ok (Cod f) (f a)
type Dom f :: CatKind
type Cod f :: CatKind
fmap :: (Ok (Dom f) a, Ok (Dom f) b) => Dom f a b -> Cod f (f a) (f b)
```

and the previously-failing instance declaration becomes

```
instance (Functor f, Dom f ~ NFun, Cod f ~ NFun) => Functor (NIdF f) where
type Dom (NIdF f) = Dom f
type Cod (NIdF f) = Cod f
proveFunctor :: forall a. Ok (Dom (NIdF f)) a
=> Ok (Dom (NIdF f)) a :- Ok (Cod (NIdF f)) ((NIdF f) a)
proveFunctor = Sub Dict
\\ (proveFunctor @f :: Ok (Dom f) a :- Ok (Cod f) (f a))
fmap f = NFun \(NIdF xs) -> NIdF (neval (fmap f) xs)
```

The disadvantage is that `proveFunctor`

is now an explicit function, and using `fmap`

now might require calling `proveFunctor`

explicitly to invoke it as proof.

While experimenting with quantified constraints, I find I need to explicitly specify a quantified constraint in an instance declaration that I think should be deduced automatically. When I leave it out, GHC complains that it cannot deduce `Num (f a)`

in the code below.

The full source code is attached. The relevant lines are

```
instance ( Functor f, Dom f ~ NFun, Cod f ~ NFun
, forall a. Ok NFun a => Num a -- I don't want to write this constraint
) => Functor (NIdF f) where
type Dom (NIdF f) = Dom f
type Cod (NIdF f) = Cod f
fmap f = NFun \(NIdF xs) -> NIdF (neval (fmap f) xs)
```

where the line marked "I don't want to write ..." points to the constraint I don't want to have to write manually. The definition of the `NFun`

is

```
instance Category NFun where
type Ok NFun a = Num a
id = NFun P.id
NFun g . NFun f = NFun (g P.. f)
```

Note that the constraint in question does not involve the type `NIdF`

for which the instance is declared – it is a generic condition that is always true, given the instance declaration of `NFun`

(see the definition of `Ok`

there).

Trac field | Value |
---|---|

Version | 8.6.3 |

Type | Bug |

TypeOfFailure | OtherFailure |

Priority | normal |

Resolution | Unresolved |

Component | Compiler |

Test case | |

Differential revisions | |

BlockedBy | |

Related | |

Blocking | |

CC | |

Operating system | |

Architecture |