kowainik / stan

🕵️ Haskell STatic ANalyser
https://kowainik.github.io/projects/stan
Mozilla Public License 2.0
565 stars 48 forks source link

Inspection on too restrictive SPECIALIZE #361

Open chshersh opened 4 years ago

chshersh commented 4 years ago

If you have a function of type:

foo :: MonadIO m => m a

then the following specializations are either useless or too restrictive:

{-# SPECIALIZE foo :: MonadIO m => m () #-}
{-# SPECIALIZE foo :: IO () #-}

The only correct one is:

{-# SPECIALIZE foo :: IO a #-}

But since GHC doesn't warn on such cases, it's useful for Stan to provide such type of analysis.