Changes between Version 10 and Version 11 of Design/LocalWarningPragmas
 Timestamp:
 Dec 4, 2015 12:43:11 PM (4 years ago)
Legend:
 Unmodified
 Added
 Removed
 Modified

Design/LocalWarningPragmas
v10 v11 20 20 It is not very easy to form a good use case for this but nevertheless. 21 21 22 1. For example, if you depend on particular library function(if you want to support backward compatability) but in newer version of library this function marked as deprecated and so you get warnings about it. Here it may be useful to suppress them instead of rewriting the whole codebase. 22 1. For example, if you depend on particular library function(if you want to support backward compatability) but in newer version of library this function marked as deprecated and so you get warnings about it. Here it may be useful to suppress them instead of rewriting the whole codebase. I have asked about use cases on [https://www.reddit.com/r/haskell/comments/3rbpb6/examples_of_warnings_in_haskell/ Haskell's reddit cahnnel] 23 23 2. Recent monad of no return proposal suggests that having `Applicative` context sufficed for `Monad` assumes that `return` is already implemented as `pure`, so we don't need to duplicate code. However, Monad still has minimal complete definition `>>=` and `return`, so we can have warnings about incomplete minimal definition. 24 24 … … 38 38 39 39 bar :: a > b > c 40 {# SUPPRESS foo#}40 {# SUPPRESS bar #} 41 41 bar x y = foo y $ x 42 42 }}} 43 43 44 We are suppressing warnings for one particular function 44 We are suppressing warnings for one particular function. By writing `{# SUPPRESS bar #}` i mean that all warnings that function `bar` throws will be suppressed. 45 46 Another example: 45 47 46 48 {{{#!hs 47 {# SUPPRESS return #} 48 instance Applicative m => Monad m where 49 (>>=) = ... 49 50 module Test where 51 52 {# SUPPRESS foo #} 53 foo :: Integer > Integer 54 foo n  n >= 0 = fac n 55  n < 0 = n + 1 56 where 57 fac x  x == 0 = 1 58  x /= 0 = x * fac (x  1) 59 foo _ = undefined 50 60 51 61 }}} 52 And here we are suppressing warnings about incomplete minimal53 62 63 With Wall GHC will warn us about incomplete pattern matching for `fac` however, `fac` is used and defined only when `n >= 0`. So we write `{# SUPPRESS foo #}` and this warning(and others that `foo` throws) will be suppressed and not printed to user. 64