diff options
author | Bodigrim <andrew.lelechenko@gmail.com> | 2023-01-23 20:56:10 +0000 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2023-01-28 17:16:11 -0500 |
commit | 2b62739d7e6cc65f444029f252578f2dddb95ce3 (patch) | |
tree | 4df4fd28ce0e7b05d991fad8922cee4bceacc5fd /libraries/base/Data | |
parent | 6ea2aa0293aedea2f873b7b5d9cff5e7b9e2f188 (diff) | |
download | haskell-2b62739d7e6cc65f444029f252578f2dddb95ce3.tar.gz |
Assorted changes to avoid Data.List.{head,tail}
Diffstat (limited to 'libraries/base/Data')
-rw-r--r-- | libraries/base/Data/Data.hs | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/libraries/base/Data/Data.hs b/libraries/base/Data/Data.hs index 1a081484a9..5fcecc867a 100644 --- a/libraries/base/Data/Data.hs +++ b/libraries/base/Data/Data.hs @@ -704,10 +704,9 @@ readConstr dt str = -- Traverse list of algebraic datatype constructors idx :: [Constr] -> Maybe Constr - idx cons = let fit = filter ((==) str . showConstr) cons - in if fit == [] - then Nothing - else Just (head fit) + idx cons = case filter ((==) str . showConstr) cons of + [] -> Nothing + hd : _ -> Just hd ffloat :: Double -> Constr ffloat = mkPrimCon dt str . FloatConstr . toRational @@ -850,17 +849,17 @@ isNorepType dt = case datarep dt of -- drop *.*.*... before name -- tyconUQname :: String -> String -tyconUQname x = let x' = dropWhile (not . (==) '.') x - in if x' == [] then x else tyconUQname (tail x') +tyconUQname x = case dropWhile (not . (==) '.') x of + [] -> x + _ : tl -> tyconUQname tl -- | Gets the module of a type constructor: -- take *.*.*... before name tyconModule :: String -> String -tyconModule x = let (a,b) = break ((==) '.') x - in if b == "" - then b - else a ++ tyconModule' (tail b) +tyconModule x = case break ((==) '.') x of + (_, "") -> "" + (a, _ : tl) -> a ++ tyconModule' tl where tyconModule' y = let y' = tyconModule y in if y' == "" then "" else ('.':y') |