Skip to content

Commit

Permalink
Apply hlint suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
turion committed May 12, 2023
1 parent 9c15939 commit 0109a8a
Show file tree
Hide file tree
Showing 11 changed files with 81 additions and 16 deletions.
66 changes: 66 additions & 0 deletions .hlint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# 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]
- arguments: [-XArrows]

# 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


# 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
1 change: 1 addition & 0 deletions rhine-examples/src/ADSR.hs
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ decay
-> Behaviour (ExceptT (Diff time) m) time amplitude
decay d = linearly d 1

{- HLINT ignore sustain "Eta reduce" -} -- Doesn't compile on GHC 9.0 otherwise
-- | A period in which a given amplitude is sustained indefinitely.
sustain :: Monad m => amplitude -> Behaviour m time amplitude
sustain amplitude = arr_ amplitude
Expand Down
6 changes: 3 additions & 3 deletions rhine-examples/src/EventClock.hs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ responsive = timeInfo >>> proc TimeInfo {..} -> do
randomsExample :: IO ()
randomsExample = runEventChanT $ flow wholeSystem
where
busy = (liftClock Busy :: HoistClock IO EventIO Busy) -- TODO Can't remove brackets. GHC parser bug?
busy = liftClock Busy :: HoistClock IO EventIO Busy
emitEventSystem = randomNumbers >-> emitS @@ busy
handleEventSystem = handleEvents @@ EventClock
eventSystem = emitEventSystem ||@ concurrentlyWithEvents @|| handleEventSystem
Expand All @@ -93,8 +93,8 @@ threadsRandomsExample = do
let
eventClock = eventClockOn chan :: HoistClock EventIO IO (EventClock String)
eventSystem = handleEvents @@ eventClock ||@ concurrently @|| responsive @@ waitClock
busy = (liftClock Busy :: HoistClock IO EventIO Busy) -- TODO Can't remove brackets. GHC parser bug?
void $ forkIO $ flow $ eventSystem
busy = liftClock Busy :: HoistClock IO EventIO Busy
void $ forkIO $ flow eventSystem
withChan chan $ flow $ randomNumbers >-> emitS' @@ busy


Expand Down
2 changes: 1 addition & 1 deletion rhine-gloss/src/FRP/Rhine/Gloss/Pure.hs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,6 @@ flowGlossWithWorldMSF GlossSettings { .. } clock msf
(time, tag) <- fst $ fst $ runWriter $ flip runReaderT (0, Nothing) $ unGlossM $ initClock clock -< ()
msf -< (time, tag)
getPic (_, pic) = pic
stepWith (diff, maybeEvent) (msf, _) = snd *** id $ runWriter $ unMSF msf ((diff, maybeEvent), ())
stepWith (diff, maybeEvent) (msf, _) = first snd $ runWriter $ unMSF msf ((diff, maybeEvent), ())
handleEvent event = stepWith (0, Just event)
simStep diff = stepWith (diff, Nothing)
6 changes: 2 additions & 4 deletions rhine/src/FRP/Rhine/ClSF/Random.hs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ runRandS
=> ClSF (RandT g m) cl a b
-> g -- ^ The initial random seed
-> ClSF m cl a (g, b)
runRandS clsf g = MSF.runRandS (morphS commuteReaderRand clsf) g
runRandS clsf = MSF.runRandS (morphS commuteReaderRand clsf)

-- | Updates the generator every step but discards the generator.
evalRandS
Expand All @@ -59,9 +59,7 @@ evalRandIOS
:: Monad m
=> ClSF (RandT StdGen m) cl a b
-> IO (ClSF m cl a b)
evalRandIOS clsf = do
g <- newStdGen
return $ evalRandS clsf g
evalRandIOS clsf = evalRandS clsf <$> newStdGen

-- | Evaluates the random computation by using the global random generator on the first tick.
evalRandIOS'
Expand Down
2 changes: 1 addition & 1 deletion rhine/src/FRP/Rhine/ClSF/Reader.hs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ runReaderS
:: Monad m
=> ClSF (ReaderT r m) cl a b -> ClSF m cl (a, r) b
runReaderS behaviour
= arr swap >>> (MSF.runReaderS $ morphS commuteReaders behaviour)
= arr swap >>> MSF.runReaderS (morphS commuteReaders behaviour)

-- | Remove a 'ReaderT' layer by passing the readonly environment explicitly.
runReaderS_
Expand Down
2 changes: 1 addition & 1 deletion rhine/src/FRP/Rhine/Clock/FixedStep.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ and a deterministic schedule for such clocks.
{-# LANGUAGE GADTs #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}

module FRP.Rhine.Clock.FixedStep where


Expand Down
2 changes: 1 addition & 1 deletion rhine/src/FRP/Rhine/Clock/Realtime/Millisecond.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Provides a clock that ticks at every multiple of a fixed number of milliseconds.
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}

module FRP.Rhine.Clock.Realtime.Millisecond where

-- base
Expand Down
4 changes: 2 additions & 2 deletions rhine/src/FRP/Rhine/ResamplingBuffer/Interpolation.hs
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ which should be chosen much larger than the average time between @cl1@'s ticks.
sinc
:: ( Monad m, Clock m cl1, Clock m cl2
, VectorSpace v s
, Ord (s)
, Floating (s)
, Ord s
, Floating s
, s ~ Diff (Time cl1)
, s ~ Diff (Time cl2)
)
Expand Down
4 changes: 2 additions & 2 deletions rhine/src/FRP/Rhine/ResamplingBuffer/KeepLast.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ import FRP.Rhine.ResamplingBuffer.Timeless
keepLast :: Monad m => a -> ResamplingBuffer m cl1 cl2 a a
keepLast = timelessResamplingBuffer AsyncMealy {..}
where
amPut _ a = return a
amGet a = return (a, a)
amGet a = return (a, a)
amPut _ = return
2 changes: 1 addition & 1 deletion rhine/src/FRP/Rhine/Schedule/Concurrently.hs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ concurrentlyExcept = Schedule $ \cl1 cl2 -> do
putMVar mvar $ Left e -- Either throw own exception or acknowledge the exception from the other clock
Left e -> void $ putMVar iMVar $ Left e
catchAndDrain mvar initScheduleAction = catchE initScheduleAction $ \e -> do
_ <- reactimate $ (constM $ ExceptT $ takeMVar mvar) >>> arr (const ()) -- Drain the mvar until the other clock acknowledges the exception
_ <- reactimate $ constM (ExceptT $ takeMVar mvar) >>> arr (const ()) -- Drain the mvar until the other clock acknowledges the exception
throwE e

-- | As 'concurrentlyExcept', with a single possible exception value.
Expand Down

0 comments on commit 0109a8a

Please sign in to comment.