User Tools

Site Tools


codesnippets:fnowarnmissingsignatures

{-# OPTIONS_GHC -fno-warn-missing-signatures #-}

  • Prevents warnings of top level functions which have no type signature.
  • NOTE: For better readability, sometimes it makes sense not to declate the type of top level functions and letting the compiler to infer the type.
  • expample:
    ...
     
    import Parser
     
    ...
     
    synMain = SynSeq [synNumber, synComment, synNumber, SynEOI]
    synComment = SynSeq [ synCommentBegin, synNotCommentEnds, synCommentEnd]
    synCommentBegin = SynSeq [SynChar '{', SynChar '-']
    synCommentEnd = SynSeq [SynChar '-', SynChar '}']
    synNotCommentEnds = SynRep synNotCommentEnd
    synNotCommentEnd = SynAbs synCommentEnd
    synNumber = SynSel [synNumberZero,synNonZeroNumber]
    synNumberZero = SynChar '0'
    synNonZeroNumber = SynSeq [synNonZeroDigit, SynRep synDigit]
    synNonZeroDigit = SynSel (map SynChar ['1'..'9'])
    synDigit = SynSel (map SynChar ['0'..'9'])
  • compiler warning, when using -Wall:
    app\Main.hs:59:1: warning: [-Wmissing-signatures]
        Top-level binding with no type signature: synMain :: Syntax
       |
    59 | synMain = SynSeq [synNumber, synComment, synNumber, SynEOI]
       | ^^^^^^^
  • expample:
    {-# OPTIONS_GHC -fno-warn-missing-signatures #-}
     
    ...
     
    import Parser
     
    ...
     
    synMain = SynSeq [synNumber, synComment, synNumber, SynEOI]
    synComment = SynSeq [ synCommentBegin, synNotCommentEnds, synCommentEnd]
    synCommentBegin = SynSeq [SynChar '{', SynChar '-']
    synCommentEnd = SynSeq [SynChar '-', SynChar '}']
    synNotCommentEnds = SynRep synNotCommentEnd
    synNotCommentEnd = SynAbs synCommentEnd
    synNumber = SynSel [synNumberZero,synNonZeroNumber]
    synNumberZero = SynChar '0'
    synNonZeroNumber = SynSeq [synNonZeroDigit, SynRep synDigit]
    synNonZeroDigit = SynSel (map SynChar ['1'..'9'])
    synDigit = SynSel (map SynChar ['0'..'9'])
    • compiles, error and warning free, with compiler: GHC 9.0.2, using compiler option -Wall

This website uses cookies. By using the website, you agree with storing cookies on your computer. Also you acknowledge that you have read and understand our Privacy Policy. If you do not agree leave the website.More information about cookies
You could leave a comment if you were logged in.
codesnippets/fnowarnmissingsignatures.txt · Last modified: by 127.0.0.1

Except where otherwise noted, content on this wiki is licensed under the following license: CC0 1.0 Universal
CC0 1.0 Universal Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki