{-# LANGUAGE BangPatterns #-}
import Control.Monad
import qualified Data.ByteString.Char8 as BS
import Data.Maybe
import Data.List
readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine
f :: Char -> String -> Int
f c [] = 0
f c (s:ss) = if c == s then 1 + ( f c ss ) else f c ss
g' :: Char -> String -> String
g' c [] = []
g' c (s:ss)
| c == s = g' c ss
| otherwise = s:(g' c ss)
g :: Int -> [Int] -> String -> String -> String
g m [] _ s = s
g m l t s
| m == head l = g m (tail l) (tail t) (g' (head t) s)
| otherwise = g m (tail l) (tail t) s
main = do
s <- getLine
let l = (flip f s) <$> ['a'..'z']
let m = maximum l
-- print m
putStrLn $ g m l ['a'..'z'] s
Configuration is affected by the following files:
- cabal.project
- cabal.project.freeze
- cabal.project.local
app/Main.hs:2:1: warning: [GHC-66111] [-Wunused-imports]
The import of ‘Control.Monad’ is redundant
except perhaps to import instances from ‘Control.Monad’
To import instances alone, use: import Control.Monad()
|
2 | import Control.Monad
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/Main.hs:5:1: warning: [GHC-66111] [-Wunused-imports]
The import of ‘Data.List’ is redundant
except perhaps to import instances from ‘Data.List’
To import instances alone, use: import Data.List()
|
5 | import Data.List
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
app/Main.hs:6:1: warning: [GHC-38417] [-Wmissing-signatures]
Top-level binding with no type signature:
readInt :: BS.ByteString -> Int
|
6 | readInt = fst . fromJust . BS.readInt
| ^^^^^^^
app/Main.hs:6:1: warning: [GHC-40910] [-Wunused-top-binds]
Defined but not used: ‘readInt’
|
6 | readInt = fst . fromJust . BS.readInt
| ^^^^^^^
app/Main.hs:7:1: warning: [GHC-38417] [-Wmissing-signatures]
Top-level binding with no type signature:
readIntList :: BS.ByteString -> [Int]
|
7 | readIntList = map readInt . BS.words
| ^^^^^^^^^^^
app/Main.hs:7:1: warning: [GHC-40910] [-Wunused-top-binds]
Defined but not used: ‘readIntList’
|
7 | readIntList = map readInt . BS.words
| ^^^^^^^^^^^
app/Main.hs:8:1: warning: [GHC-38417] [-Wmissing-signatures]
Top-level binding with no type signature: getInt :: IO Int
|
8 | getInt = readInt <$> BS.getLine
| ^^^^^^
app/Main.hs:8:1: warning: [GHC-40910] [-Wunused-top-binds]
Defined but not used: ‘getInt’
|
8 | getInt = readInt <$> BS.getLine
| ^^^^^^
app/Main.hs:9:1: warning: [GHC-38417] [-Wmissing-signatures]
Top-level binding with no type signature: getIntList :: IO [Int]
|
9 | getIntList = readIntList <$> BS.getLine
| ^^^^^^^^^^
app/Main.hs:9:1: warning: [GHC-40910] [-Wunused-top-binds]
Defined but not used: ‘getIntList’
|
9 | getIntList = readIntList <$> BS.getLine
| ^^^^^^^^^^
app/Main.hs:11:3: warning: [GHC-40910] [-Wunused-matches]
Defined but not used: ‘c’
|
11 | f c [] = 0
| ^
app/Main.hs:14:4: warning: [GHC-40910] [-Wunused-matches]
Defined but not used: ‘c’
|
14 | g' c [] = []
| ^
app/Main.hs:19:3: warning: [GHC-40910] [-Wunused-matches]
Defined but not used: ‘m’
|
19 | g m [] _ s = s
| ^
app/Main.hs:21:12: warning: [GHC-63394] [-Wx-partial]
In the use of ‘head’
(imported from Data.List, but defined in GHC.List):
"This is a partial function, it throws an error on empty lists. Use pattern matching or Data.List.uncons instead. Consider refactoring to use Data.List.NonEmpty."
|
21 | | m == head l = g m (tail l) (tail t) (g' (head t) s)
| ^^^^
app/Main.hs:21:26: warning: [GHC-63394] [-Wx-partial]
In the use of ‘tail’
(imported from Data.List, but defined in GHC.List):
"This is a partial function, it throws an error on empty lists. Replace it with drop 1, or use pattern matching or Data.List.uncons instead. Consider refactoring to use Data.List.NonEmpty."
|
21 | | m == head l = g m (tail l) (tail t) (g' (head t) s)
| ^^^^
app/Main.hs:21:35: warning: [GHC-63394] [-Wx-partial]
In the use of ‘tail’
(imported from Data.List, but defined in GHC.List):
"This is a partial function, it throws an error on empty lists. Replace it with drop 1, or use pattern matching or Data.List.uncons instead. Consider refactoring to use Data.List.NonEmpty."
|
21 | | m == head l = g m (tail l) (tail t) (g' (head t) s)
| ^^^^
app/Main.hs:21:48: warning: [GHC-63394] [-Wx-partial]
In the use of ‘head’
(imported from Data.List, but defined in GHC.List):
"This is a partial function, it throws an error on empty lists. Use pattern matching or Data.List.uncons instead. Consider refactoring to use Data.List.NonEmpty."
|
21 | | m == head l = g m (tail l) (tail t) (g' (head t) s)
| ^^^^
app/Main.hs:22:24: warning: [GHC-63394] [-Wx-partial]
In the use of ‘tail’
(imported from Data.List, but defined in GHC.List):
"This is a partial function, it throws an error on empty lists. Replace it with drop 1, or use pattern matching or Data.List.uncons instead. Consider refactoring to use Data.List.NonEmpty."
|
22 | | otherwise = g m (tail l) (tail t) s
| ^^^^
app/Main.hs:22:33: warning: [GHC-63394] [-Wx-partial]
In the use of ‘tail’
(imported from Data.List, but defined in GHC.List):
"This is a partial function, it throws an error on empty lists. Replace it with drop 1, or use pattern matching or Data.List.uncons instead. Consider refactoring to use Data.List.NonEmpty."
|
22 | | otherwise = g m (tail l) (tail t) s
| ^^^^
app/Main.hs:23:1: warning: [GHC-38417] [-Wmissing-signatures]
Top-level binding with no type signature: main :: IO ()
|
23 | main = do
| ^^^^
Configuration is affected by the following files:
- cabal.project
- cabal.project.freeze
- cabal.project.local