Attached file `0001-Split-ghci-info-into-info-and-instances.patch`

(download).

Attached file `ghci-info-no-instances.patch`

(download).

patch to optionally not print instances with :info

Attached file `Test2.hs`

($176).

Test module for the second case where it breaks

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

Architecture | aarch64 → Unknown/Multiple |

```
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE ScopedTypeVariables #-}
module Oops where
pattern What = True :: Maybe
```

Fails on 8.4.3 with:

```
ghc: panic! (the 'impossible' happened)
(GHC version 8.4.3 for x86_64-unknown-linux):
isUnliftedType
(Maybe |> {co_a1Dg3}) :: TYPE t_a1Dg9[tau:1]
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/utils/Outputable.hs:1150:37 in ghc:Outputable
pprPanic, called at compiler/types/Type.hs:1939:10 in ghc:Type
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
```

I'm currently cloning from git, and will try to get around to check it with HEAD over the next days. BTW, it's not a show-stopper for me.

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

Version | 8.4.3 |

Type | Bug |

TypeOfFailure | OtherFailure |

Priority | low |

Resolution | Unresolved |

Component | Compiler (Type checker) |

Test case | |

Differential revisions | |

BlockedBy | |

Related | |

Blocking | |

CC | |

Operating system | |

Architecture | aarch64 |

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

CC | remi.turk@gmail.com, simonmar → remi, simonmar |

Thanks for reminding that I want this feature, hvr :) I had an unexpected day off work and decided to finally dig up and work a bit on that patch:

```
Prelude> :info Maybe Monad
data Maybe a = Nothing | Just a -- Defined in ‘GHC.Base’
Use `:instances Maybe' to see its 10 instance(s)
class Applicative m => Monad (m :: * -> *) where
(>>=) :: m a -> (a -> m b) -> m b
(>>) :: m a -> m b -> m b
return :: a -> m a
fail :: String -> m a
-- Defined in ‘GHC.Base’
Use `:instances Monad' to see its 5 instance(s)
```

And for instances:

```
Prelude> :instances Maybe Monad
instance Eq a => Eq (Maybe a) -- Defined in ‘GHC.Base’
instance Monad Maybe -- Defined in ‘GHC.Base’
instance Functor Maybe -- Defined in ‘GHC.Base’
instance Ord a => Ord (Maybe a) -- Defined in ‘GHC.Base’
instance Read a => Read (Maybe a) -- Defined in ‘GHC.Read’
instance Show a => Show (Maybe a) -- Defined in ‘GHC.Show’
instance Applicative Maybe -- Defined in ‘GHC.Base’
instance Foldable Maybe -- Defined in ‘Data.Foldable’
instance Traversable Maybe -- Defined in ‘Data.Traversable’
instance Monoid a => Monoid (Maybe a) -- Defined in ‘GHC.Base’
instance Monad (Either e) -- Defined in ‘Data.Either’
instance Monad [] -- Defined in ‘GHC.Base’
instance Monad Maybe -- Defined in ‘GHC.Base’
instance Monad IO -- Defined in ‘GHC.Base’
instance Monad ((->) r) -- Defined in ‘GHC.Base’
```

```
Prelude> :instances! Monad
instance Monad Data.Functor.Identity.Identity
-- Defined in ‘Data.Functor.Identity’
instance Monad Data.Monoid.Last -- Defined in ‘Data.Monoid’
instance Monad Data.Monoid.First -- Defined in ‘Data.Monoid’
instance Monad f => Monad (Data.Monoid.Alt f)
-- Defined in ‘Data.Monoid’
instance Monad Text.ParserCombinators.ReadPrec.ReadPrec
-- Defined in ‘Text.ParserCombinators.ReadPrec’
instance Monad (GHC.ST.ST s) -- Defined in ‘GHC.ST’
instance Control.Arrow.ArrowApply a =>
Monad (Control.Arrow.ArrowMonad a)
-- Defined in ‘Control.Arrow’
instance Monad m => Monad (Control.Applicative.WrappedMonad m)
-- Defined in ‘Control.Applicative’
instance Monad Data.Proxy.Proxy -- Defined in ‘Data.Proxy’
instance Monad Text.ParserCombinators.ReadP.ReadP
-- Defined in ‘Text.ParserCombinators.ReadP’
instance Monad Text.ParserCombinators.ReadP.P
-- Defined in ‘Text.ParserCombinators.ReadP’
instance Monad (Either e) -- Defined in ‘Data.Either’
instance Monad [] -- Defined in ‘GHC.Base’
instance Monad Maybe -- Defined in ‘GHC.Base’
instance Monad IO -- Defined in ‘GHC.Base’
instance Monad ((->) r) -- Defined in ‘GHC.Base’
instance Data.Typeable.Internal.Typeable Monad
-- Defined in ‘Data.Typeable.Internal’
```

What it doesn't support is at least:

```
Prelude> :set -XDataKinds
Prelude> :instances Just
`Just' is not a type or class
Prelude> :instances 'Just
<interactive>:1:1: parse error on input ‘'’
Prelude> :k 'Just
'Just :: k -> Maybe k
Prelude> :k Just
Just :: k -> Maybe k
```

However, :info doesn't support it either, so I don't think that's that much of an issue right now:

```
Prelude> :info 'Just
<interactive>:1:1: parse error on input ‘'’
```

This is probably going to be the longest standing feature request ever, but half a year after losing the previous version of my patch I got around to creating a new one. However, before I polish and post it, I'd like to get you guys' opinion on something I hacked^Wadded to it:

```
*InteractiveUI Control.Monad> :instances Monad
Monad GHCi
Monad Lexer.P
Monad (Either e)
Monad m => Monad (InputT m)
Monad Maybe
Monad m => Monad (GHC.GhcT m)
Monad Ghc
Monad []
Monad IO
Monad ((->) r)
*InteractiveUI Control.Monad>
*InteractiveUI Control.Monad> :i Monad []
class Monad m where
(>>=) :: m a -> (a -> m b) -> m b
(>>) :: m a -> m b -> m b
return :: a -> m a
fail :: String -> m a
-- Defined in `GHC.Base'
{- (->) r, [], Either e, Ghc, GHCi, GhcT m, InputT m, IO, Maybe,
P -}
data [] a = [] | a : [a] -- Defined in `GHC.Types'
{- Alternative, Applicative, Eq, Functor, Monad, MonadPlus, Ord,
Outputable, PrintfArg, PrintfType, Read, Show -}
```

The question being, what do you think about the instance-summary with :info?

I'm rather busy at my job currently so it may take awhile, but I'll see what I can do :)

The reason I chose the minus-version is because it was the smallest version, and didn't change the default behaviour, but I personally prefer Simon's suggestion too, at least if :i keeps meaning :info...

Perhaps unsurprising, I second the suggestion to apply this patch.

When concurrently calling safe FFI functions, worker OS threads are created. These threads then never quit.

The following toy program creates 30k OS threads (which is fine because that's exactly what it asks for) which are then never "garbage collected": 30k threads and over 230g of VM are hanging around until the program exits.

```
{-# LANGUAGE ForeignFunctionInterface #-}
module Main where
import Control.Concurrent
import Control.Monad
import Foreign.C.Types
import System.Mem
foreign import ccall safe sleep :: CUInt -> IO ()
main = do
replicateM_ 30000 $ forkIO $ sleep 2
getLine
-- do other stuff
```

P.S. Of course I should simply use threadDelay in this case. The real program performs up to a few hundred concurrent fdatasync calls.

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

Version | 6.12.3 |

Type | Bug |

TypeOfFailure | OtherFailure |

Priority | normal |

Resolution | Unresolved |

Component | Runtime System |

Test case | |

Differential revisions | |

BlockedBy | |

Related | |

Blocking | |

CC | |

Operating system | |

Architecture |