Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Q
quasar
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jens Nolte
quasar
Commits
6d26911d
Commit
6d26911d
authored
2 years ago
by
Jens Nolte
Browse files
Options
Downloads
Patches
Plain Diff
Convert trace warnings to hlint rules
Co-authored-by:
Jan Beinke
<
git@janbeinke.com
>
parent
a9c2fe5b
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
.hlint.yaml
+79
-0
79 additions, 0 deletions
.hlint.yaml
flake.nix
+1
-0
1 addition, 0 deletions
flake.nix
src/Quasar/Prelude.hs
+13
-55
13 additions, 55 deletions
src/Quasar/Prelude.hs
with
93 additions
and
55 deletions
.hlint.yaml
0 → 100644
+
79
−
0
View file @
6d26911d
# HLint configuration file
# https://github.com/ndmitchell/hlint
##########################
# This file contains a template configuration file, which is typically
# placed as .hlint.yaml in the root of your project
# Specify additional command line arguments
#
# - arguments: [--color, --cpp-simple, -XQuasiQuotes]
# Control which extensions/flags/modules/functions can be used
#
# - extensions:
# - default: false # all extension are banned by default
# - name: [PatternGuards, ViewPatterns] # only these listed extensions can be used
# - {name: CPP, within: CrossPlatform} # CPP can only be used in a given module
#
# - flags:
# - {name: -w, within: []} # -w is allowed nowhere
#
# - modules:
# - {name: [Data.Set, Data.HashSet], as: Set} # if you import Data.Set qualified, it must be as 'Set'
# - {name: Control.Arrow, within: []} # Certain modules are banned entirely
#
# - functions:
# - {name: unsafePerformIO, within: []} # unsafePerformIO can only appear in no modules
-
functions
:
-
message
:
"
Traces
are
not
allowed
in
production
code"
within
:
[
Quasar.Prelude
]
name
:
-
trace
-
traceId
-
traceShow
-
traceShowId
-
traceM
-
traceShowM
-
traceIO
-
traceShowIO
-
traceShowIdIO
# Add custom hints for this project
#
# Will suggest replacing "wibbleMany [myvar]" with "wibbleOne myvar"
# - error: {lhs: "wibbleMany [x]", rhs: wibbleOne x}
# The hints are named by the string they display in warning messages.
# For example, if you see a warning starting like
#
# Main.hs:116:51: Warning: Redundant ==
#
# You can refer to that hint with `{name: Redundant ==}` (see below).
# Turn on hints that are off by default
#
# Ban "module X(module X) where", to require a real export list
# - warn: {name: Use explicit module export list}
#
# Replace a $ b $ c with a . b $ c
# - group: {name: dollar, enabled: true}
#
# Generalise map to fmap, ++ to <>
# - group: {name: generalise, enabled: true}
# Ignore some builtin hints
# - ignore: {name: Use let}
# - ignore: {name: Use const, within: SpecialModule} # Only within certain modules
# Define some custom infix operators
# - fixity: infixr 3 ~^#^~
# To generate a suitable file for HLint do:
# $ hlint --default > .hlint.yaml
This diff is collapsed.
Click to expand it.
flake.nix
+
1
−
0
View file @
6d26911d
...
...
@@ -40,6 +40,7 @@
pkgs
.
entr
pkgs
.
ghcid
pkgs
.
haskell-language-server
pkgs
.
hlint
];
}
);
...
...
This diff is collapsed.
Click to expand it.
src/Quasar/Prelude.hs
+
13
−
55
View file @
6d26911d
...
...
@@ -31,8 +31,8 @@ module Quasar.Prelude
Data
.
Void
.
Void
,
Data
.
Hashable
.
Hashable
,
GHC
.
Generics
.
Generic
,
MonadIO
,
liftIO
,
Control
.
Monad
.
IO
.
Class
.
MonadIO
,
Control
.
Monad
.
IO
.
Class
.
liftIO
,
Data
.
Maybe
.
catMaybes
,
Data
.
Maybe
.
fromMaybe
,
Data
.
Maybe
.
isJust
,
...
...
@@ -49,15 +49,12 @@ module Quasar.Prelude
Data
.
Word
.
Word64
,
error
,
errorWithoutStackTrace
,
head
,
last
,
read
,
trace
,
traceId
,
traceShow
,
traceShowId
,
traceM
,
traceShowM
,
Debug
.
Trace
.
trace
,
Debug
.
Trace
.
traceId
,
Debug
.
Trace
.
traceShow
,
Debug
.
Trace
.
traceShowId
,
Debug
.
Trace
.
traceM
,
Debug
.
Trace
.
traceShowM
,
traceIO
,
traceShowIO
,
traceShowIdIO
,
...
...
@@ -86,7 +83,7 @@ import Control.Exception qualified
import
Control.Monad
((
>=>
),
(
<=<
))
import
Control.Monad
qualified
import
Control.Monad.Fix
qualified
import
Control.Monad.IO.Class
(
MonadIO
,
liftIO
)
import
Control.Monad.IO.Class
qualified
import
Data.Foldable
qualified
import
Data.Functor.Identity
qualified
import
Data.Hashable
qualified
...
...
@@ -96,25 +93,13 @@ import Data.Maybe qualified
import
Data.Unique
qualified
import
Data.Void
qualified
import
Data.Word
qualified
import
Debug.Trace
qualified
as
Trace
import
Debug.Trace
qualified
import
GHC.Generics
qualified
import
GHC.Stack.Types
qualified
import
GHC.Types
qualified
import
Quasar.PreludeExtras
import
Quasar.PreludeSTM
{-# WARNING head "Partial Function." #-}
head
::
[
a
]
->
a
head
=
P
.
head
{-# WARNING last "Partial Function." #-}
last
::
[
a
]
->
a
last
=
P
.
last
{-# WARNING read "Partial Function." #-}
read
::
Read
a
=>
String
->
a
read
=
P
.
read
{-# WARNING error "Undefined." #-}
error
::
forall
(
r
::
GHC
.
Types
.
RuntimeRep
)
.
forall
(
a
::
GHC
.
Types
.
TYPE
r
)
.
GHC
.
Stack
.
Types
.
HasCallStack
=>
String
->
a
error
=
P
.
error
...
...
@@ -127,41 +112,14 @@ errorWithoutStackTrace = P.errorWithoutStackTrace
undefined
::
forall
(
r
::
GHC
.
Types
.
RuntimeRep
)
.
forall
(
a
::
GHC
.
Types
.
TYPE
r
)
.
GHC
.
Stack
.
Types
.
HasCallStack
=>
a
undefined
=
P
.
undefined
{-# WARNING trace "Trace." #-}
trace
::
String
->
a
->
a
trace
=
Trace
.
trace
{-# WARNING traceId "Trace." #-}
traceId
::
String
->
String
traceId
=
Trace
.
traceId
{-# WARNING traceShow "Trace." #-}
traceShow
::
Show
a
=>
a
->
b
->
b
traceShow
=
Trace
.
traceShow
{-# WARNING traceShowId "Trace." #-}
traceShowId
::
Show
a
=>
a
->
a
traceShowId
=
Trace
.
traceShowId
{-# WARNING traceM "Trace." #-}
traceM
::
Applicative
m
=>
String
->
m
()
traceM
=
Trace
.
traceM
{-# WARNING traceShowM "Trace." #-}
traceShowM
::
(
Show
a
,
Applicative
m
)
=>
a
->
m
()
traceShowM
=
Trace
.
traceShowM
{-# WARNING traceIO "Trace." #-}
traceIO
::
Control
.
Monad
.
IO
.
Class
.
MonadIO
m
=>
String
->
m
()
traceIO
=
Control
.
Monad
.
IO
.
Class
.
liftIO
.
Trace
.
traceIO
traceIO
=
Control
.
Monad
.
IO
.
Class
.
liftIO
.
Debug
.
Trace
.
traceIO
{-# WARNING traceShowIO "Trace." #-}
traceShowIO
::
(
Control
.
Monad
.
IO
.
Class
.
MonadIO
m
,
Show
a
)
=>
a
->
m
()
traceShowIO
=
traceIO
.
show
{-# WARNING traceShowIdIO "Trace." #-}
traceShowIdIO
::
(
Control
.
Monad
.
IO
.
Class
.
MonadIO
m
,
Show
a
)
=>
a
->
m
a
traceShowIdIO
a
=
traceShowIO
a
>>
pure
a
newUnique
::
MonadIO
m
=>
m
Data
.
Unique
.
Unique
newUnique
=
liftIO
Data
.
Unique
.
newUnique
newUnique
::
Control
.
Monad
.
IO
.
Class
.
MonadIO
m
=>
m
Data
.
Unique
.
Unique
newUnique
=
Control
.
Monad
.
IO
.
Class
.
liftIO
Data
.
Unique
.
newUnique
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment