Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Turn off warnings for using head or tail, or remove their use. #29

Merged
merged 1 commit into from
May 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions bench/Problems/P61Bench.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{-# OPTIONS_GHC -Wno-x-partial -Wno-unrecognised-warning-flags #-}

{-|
Copyright: Copyright (C) 2021 Yoo Chung
License: GPL-3.0-or-later
Expand Down
2 changes: 1 addition & 1 deletion ninetynine.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ homepage: https://ninetynine.haskell.chungyc.org/
bug-reports: https://github.com/chungyc/ninetynine/issues
author: Yoo Chung
maintainer: [email protected]
copyright: Copyright (C) 2023 Yoo Chung
copyright: Copyright (C) 2024 Yoo Chung
license: GPL-3.0-or-later
license-file: LICENSE
build-type: Simple
Expand Down
2 changes: 2 additions & 0 deletions src/Problems/Graphs.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{-# OPTIONS_GHC -Wno-x-partial -Wno-unrecognised-warning-flags #-}

{- |
Description: Supporting definitions for graph problems
Copyright: Copyright (C) 2023 Yoo Chung
Expand Down
2 changes: 2 additions & 0 deletions src/Problems/P50.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{-# OPTIONS_GHC -Wno-x-partial -Wno-unrecognised-warning-flags #-}

{- |
Description: Huffman codes
Copyright: Copyright (C) 2021 Yoo Chung
Expand Down
2 changes: 2 additions & 0 deletions src/Problems/P91.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{-# OPTIONS_GHC -Wno-x-partial -Wno-unrecognised-warning-flags #-}

{- |
Description: Knight's tour
Copyright: Copyright (C) 2023 Yoo Chung
Expand Down
2 changes: 2 additions & 0 deletions src/Problems/P98.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{-# OPTIONS_GHC -Wno-x-partial -Wno-unrecognised-warning-flags #-}

{- |
Description: Nonograms
Copyright: Copyright (C) 2021 Yoo Chung
Expand Down
1 change: 1 addition & 0 deletions src/Problems/P99.hs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import Problems.Crosswords
import qualified Solutions.P99 as Solution

-- $setup
-- >>> :set -Wno-x-partial -Wno-unrecognised-warning-flags
-- >>> import Data.Maybe (fromJust)
-- >>> import Problems.Crosswords

Expand Down
2 changes: 2 additions & 0 deletions src/Solutions/P10.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{-# OPTIONS_GHC -Wno-x-partial -Wno-unrecognised-warning-flags #-}

{- |
Description: Run-length encoding of a list
Copyright: Copyright (C) 2021 Yoo Chung
Expand Down
2 changes: 2 additions & 0 deletions src/Solutions/P11.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{-# OPTIONS_GHC -Wno-x-partial -Wno-unrecognised-warning-flags #-}

{- |
Description: Modified run-length encoding
Copyright: Copyright (C) 2021 Yoo Chung
Expand Down
2 changes: 2 additions & 0 deletions src/Solutions/P36.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{-# OPTIONS_GHC -Wno-x-partial -Wno-unrecognised-warning-flags #-}

{- |
Description: List of prime factors and their multiplicities
Copyright: Copyright (C) 2021 Yoo Chung
Expand Down
2 changes: 2 additions & 0 deletions src/Solutions/P44.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{-# OPTIONS_GHC -Wno-x-partial -Wno-unrecognised-warning-flags #-}

{- |
Description: Gaussian primes
Copyright: Copyright (C) 2022 Yoo Chung
Expand Down
2 changes: 2 additions & 0 deletions src/Solutions/P50.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{-# OPTIONS_GHC -Wno-x-partial -Wno-unrecognised-warning-flags #-}

{- |
Description: Huffman codes
Copyright: Copyright (C) 2021 Yoo Chung
Expand Down
10 changes: 6 additions & 4 deletions src/Solutions/P79.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Some solutions to "Problems.P79" of Ninety-Nine Haskell "Problems".
-}
module Solutions.P79 (calculatePostfix) where

import Control.Monad (guard, mzero)
import Control.Monad (mzero)
import Control.Monad.Identity
import Control.Monad.State
import Control.Monad.Trans.Maybe
Expand Down Expand Up @@ -70,6 +70,8 @@ push x = modify (x:)
pop :: Calculation Integer
pop = do
xs <- get
guard $ not $ null xs
put $ tail xs
return $ head xs
case xs of
[] -> mzero
(x:xs') -> do
put xs'
return x
2 changes: 2 additions & 0 deletions src/Solutions/P82.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{-# OPTIONS_GHC -Wno-x-partial -Wno-unrecognised-warning-flags #-}

{- |
Description: Cycles with a given vertex
Copyright: Copyright (C) 2021 Yoo Chung
Expand Down
2 changes: 2 additions & 0 deletions src/Solutions/P84.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{-# OPTIONS_GHC -Wno-x-partial -Wno-unrecognised-warning-flags #-}

{- |
Description: Construct minimum spanning tree
Copyright: Copyright (C) 2021 Yoo Chung
Expand Down
2 changes: 2 additions & 0 deletions src/Solutions/P85.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{-# OPTIONS_GHC -Wno-x-partial -Wno-unrecognised-warning-flags #-}

{- |
Description: Graph isomorphism
Copyright: Copyright (C) 2023 Yoo Chung
Expand Down
2 changes: 2 additions & 0 deletions src/Solutions/P91.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{-# OPTIONS_GHC -Wno-x-partial -Wno-unrecognised-warning-flags #-}

{- |
Description: Knight's tour
Copyright: Copyright (C) 2023 Yoo Chung
Expand Down
1 change: 1 addition & 0 deletions src/Solutions/P92.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{-# OPTIONS_GHC -fno-warn-incomplete-uni-patterns #-}
{-# OPTIONS_GHC -Wno-x-partial -Wno-unrecognised-warning-flags #-}

{- |
Description: Graceful tree labeling
Expand Down
2 changes: 2 additions & 0 deletions src/Solutions/P97.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{-# OPTIONS_GHC -Wno-x-partial -Wno-unrecognised-warning-flags #-}

{- |
Description: Sudoku
Copyright: Copyright (C) 2023 Yoo Chung
Expand Down
2 changes: 2 additions & 0 deletions src/Solutions/P98.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{-# OPTIONS_GHC -Wno-x-partial -Wno-unrecognised-warning-flags #-}

{- |
Description: Nonograms
Copyright: Copyright (C) 2023 Yoo Chung
Expand Down
9 changes: 7 additions & 2 deletions src/Solutions/P99.hs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,9 @@ findSites g orient = concatMap (evalState find . initial) $ zip [0..] g
, fssChars = []
, fssLocs = []
}
step = modify $ \st -> st { fssSpots = tail $ fssSpots st
step = modify $ \st -> st { fssSpots = case fssSpots st of
[] -> error "no more spots"
(_:xs) -> xs
, fssPos = 1 + fssPos st
}

Expand Down Expand Up @@ -289,7 +291,10 @@ guess' :: RandomGen g => Partial -> State g (Maybe Partial)
guess' p = do
tiebreakers <- do gen <- state split
return (randoms gen :: [Int])
let siteIndex = snd $ head $ sortOn count $ zip tiebreakers $ Map.keys $ candidates p
let sitePicks = sortOn count $ zip tiebreakers $ Map.keys $ candidates p
let siteIndex = snd $ case sitePicks of
(x:_) -> x
[] -> error "no more sites"
wordList <- state $ randomPermute $ candidates p ! siteIndex
state $ tryGuesses p siteIndex wordList
where
Expand Down
2 changes: 2 additions & 0 deletions test/Problems/P08Spec.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{-# OPTIONS_GHC -Wno-x-partial -Wno-unrecognised-warning-flags #-}

{-|
Copyright: Copyright (C) 2023 Yoo Chung
License: GPL-3.0-or-later
Expand Down
2 changes: 2 additions & 0 deletions test/Problems/P09Spec.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{-# OPTIONS_GHC -Wno-x-partial -Wno-unrecognised-warning-flags #-}

{-|
Copyright: Copyright (C) 2023 Yoo Chung
License: GPL-3.0-or-later
Expand Down
2 changes: 2 additions & 0 deletions test/Problems/P10Spec.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{-# OPTIONS_GHC -Wno-x-partial -Wno-unrecognised-warning-flags #-}

{-|
Copyright: Copyright (C) 2023 Yoo Chung
License: GPL-3.0-or-later
Expand Down
2 changes: 2 additions & 0 deletions test/Problems/P11Spec.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{-# OPTIONS_GHC -Wno-x-partial -Wno-unrecognised-warning-flags #-}

{-|
Copyright: Copyright (C) 2023 Yoo Chung
License: GPL-3.0-or-later
Expand Down
2 changes: 2 additions & 0 deletions test/Problems/P19Spec.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{-# OPTIONS_GHC -Wno-x-partial -Wno-unrecognised-warning-flags #-}

{-|
Copyright: Copyright (C) 2023 Yoo Chung
License: GPL-3.0-or-later
Expand Down
2 changes: 2 additions & 0 deletions test/Problems/P23Spec.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{-# OPTIONS_GHC -Wno-x-partial -Wno-unrecognised-warning-flags #-}

{-|
Copyright: Copyright (C) 2023 Yoo Chung
License: GPL-3.0-or-later
Expand Down
2 changes: 2 additions & 0 deletions test/Problems/P24Spec.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{-# OPTIONS_GHC -Wno-x-partial -Wno-unrecognised-warning-flags #-}

{-|
Copyright: Copyright (C) 2023 Yoo Chung
License: GPL-3.0-or-later
Expand Down
2 changes: 2 additions & 0 deletions test/Problems/P25Spec.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{-# OPTIONS_GHC -Wno-x-partial -Wno-unrecognised-warning-flags #-}

{-|
Copyright: Copyright (C) 2023 Yoo Chung
License: GPL-3.0-or-later
Expand Down
2 changes: 2 additions & 0 deletions test/Problems/P38Spec.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{-# OPTIONS_GHC -Wno-x-partial -Wno-unrecognised-warning-flags #-}

{-|
Copyright: Copyright (C) 2023 Yoo Chung
License: GPL-3.0-or-later
Expand Down
2 changes: 2 additions & 0 deletions test/Problems/P81Spec.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{-# OPTIONS_GHC -Wno-x-partial -Wno-unrecognised-warning-flags #-}

{-|
Copyright: Copyright (C) 2023 Yoo Chung
License: GPL-3.0-or-later
Expand Down
2 changes: 2 additions & 0 deletions test/Problems/P82Spec.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{-# OPTIONS_GHC -Wno-x-partial -Wno-unrecognised-warning-flags #-}

{-|
Copyright: Copyright (C) 2023 Yoo Chung
License: GPL-3.0-or-later
Expand Down
2 changes: 2 additions & 0 deletions test/Problems/P87Spec.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{-# OPTIONS_GHC -Wno-x-partial -Wno-unrecognised-warning-flags #-}

{-|
Copyright: Copyright (C) 2023 Yoo Chung
License: GPL-3.0-or-later
Expand Down
2 changes: 2 additions & 0 deletions test/Problems/P88Spec.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{-# OPTIONS_GHC -Wno-x-partial -Wno-unrecognised-warning-flags #-}

{-|
Copyright: Copyright (C) 2023 Yoo Chung
License: GPL-3.0-or-later
Expand Down
2 changes: 2 additions & 0 deletions test/Problems/P91Spec.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{-# OPTIONS_GHC -Wno-x-partial -Wno-unrecognised-warning-flags #-}

{-|
Copyright: Copyright (C) 2023 Yoo Chung
License: GPL-3.0-or-later
Expand Down
2 changes: 2 additions & 0 deletions test/Problems/P97Spec.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{-# OPTIONS_GHC -Wno-x-partial -Wno-unrecognised-warning-flags #-}

{-|
Copyright: Copyright (C) 2023 Yoo Chung
License: GPL-3.0-or-later
Expand Down
2 changes: 2 additions & 0 deletions test/Problems/P98Spec.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{-# OPTIONS_GHC -Wno-x-partial -Wno-unrecognised-warning-flags #-}

{-|
Copyright: Copyright (C) 2023 Yoo Chung
License: GPL-3.0-or-later
Expand Down
3 changes: 2 additions & 1 deletion test/Problems/P99Spec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@ addToSolution g (w,x,y,False)
-- I.e., we don't like sites that we didn't add ourselves.
-- Reject grids which have 2x2 blank areas.
isValid :: [[Maybe Char]] -> Bool
isValid g = all isValidRows $ zip g $ tail g
isValid [] = False
isValid g@(_:gs) = all isValidRows $ zip g gs
where isValidRows ([], []) = True
isValidRows (Just _ : Just _ : _,
Just _ : Just _ : _) = False
Expand Down