Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Code improvements by HLint.

  • Loading branch information...
commit 3c5fd7620d4df5a8e2e49ca57b7d2ce33fa620d1 1 parent 8128123
@mitar authored
View
6 NXT.cabal
@@ -1,5 +1,5 @@
Name: NXT
-Version: 0.1.2
+Version: 0.1.3
Synopsis: A Haskell interface to Lego Mindstorms NXT
Description: A Haskell interface to Lego Mindstorms NXT over Bluetoooth. It supports direct commands, messages and
many sensors (also unofficial). It has also support for a simple message-based control of a NXT brick
@@ -59,7 +59,7 @@ Executable nxt-shutdown
HS-source-dirs: src
Build-depends: base >= 4 && < 5,
mtl >= 1.1 && < 2,
- NXT == 0.1.2
+ NXT == 0.1.3
GHC-options: -Wall
Executable nxt-upload
@@ -69,7 +69,7 @@ Executable nxt-upload
mtl >= 1.1 && < 2,
bytestring >= 0.9 && < 1,
filepath >= 1.1 && < 2,
- NXT == 0.1.2
+ NXT == 0.1.3
GHC-options: -Wall
GHC-prof-options: -Wall
GHC-shared-options: -Wall
View
4 lib/Robotics/NXT/Internals.hs
@@ -28,13 +28,13 @@ data NXTInternals = NXTInternals {
Runs a computation in a context of a given 'NXTInternals' token, returning a value and a new token.
-}
runNXT :: NXT a -> NXTInternals -> IO (a, NXTInternals)
-runNXT (NXT action) internals = runStateT action internals
+runNXT (NXT action) = runStateT action
{-|
Runs a computation in a context of a given 'NXTInternals' token, returning just a new token.
-}
execNXT :: NXT a -> NXTInternals -> IO NXTInternals
-execNXT (NXT action) internals = execStateT action internals
+execNXT (NXT action) = execStateT action
modifyNXT :: (NXTInternals -> NXTInternals) -> NXT ()
modifyNXT f = NXT (modify f)
View
10 lib/Robotics/NXT/MotorControl.hs
@@ -51,7 +51,7 @@ Requires dynamic\/minimal pauses.
-}
controlledMotorCmd :: [OutputPort] -> OutputPower -> TachoLimit -> [MotorControlMode] -> NXT ()
controlledMotorCmd ports power limit modes = motorControlSend message
- where message = "1" ++ (fromPorts ports) ++ (fromPower power) ++ (fromLimit limit) ++ modes'
+ where message = "1" ++ fromPorts ports ++ fromPower power ++ fromLimit limit ++ modes'
modes' = show . sum . zipWith (*) [1, 2, 4] . map (fromEnum . flip elem modes) $ [HoldBrake ..]
{-|
@@ -62,7 +62,7 @@ The same thing can be achieved by using 'resetMotorPosition' with 'InternalPosit
-}
resetErrorCorrection :: [OutputPort] -> NXT ()
resetErrorCorrection ports = motorControlSend message
- where message = "2" ++ ports'
+ where message = '2' : ports'
ports' = fromPorts ports
{-|
@@ -73,7 +73,7 @@ Implements static pauses.
-}
isMotorReady :: [OutputPort] -> NXT [Bool]
isMotorReady ports = do
- mapM_ (\port -> motorControlSend $ "3" ++ port) ports''
+ mapM_ (\port -> motorControlSend $ '3' : port) ports''
liftIO $ threadDelay (10 * 1000) -- 10 ms
replies <- mapM (\_ -> motorControlReceive) ports''
liftIO $ threadDelay (10 * 1000) -- 10 ms
@@ -89,7 +89,7 @@ Requires dynamic\/minimal pauses.
-}
classicMotorCmd :: [OutputPort] -> OutputPower -> TachoLimit -> SpeedRegulation -> NXT ()
classicMotorCmd ports power limit regulation = motorControlSend message
- where message = "4" ++ (fromPorts ports) ++ (fromPower power) ++ (fromLimit limit) ++ regulation'
+ where message = "4" ++ fromPorts ports ++ fromPower power ++ fromLimit limit ++ regulation'
regulation' | regulation = "1"
| otherwise = "0"
@@ -131,7 +131,7 @@ fromPorts ports | length ports' == 1 = show . fromEnum . head $ ports'
where ports' = sort . nub $ ports
fromPower :: OutputPower -> String
-fromPower power | (-100) <= power && power <= 100 = printf "%03d" $ if power < 0 then 100 + (abs power) else power
+fromPower power | (-100) <= power && power <= 100 = printf "%03d" $ if power < 0 then 100 + abs power else power
| otherwise = throw $ PatternMatchFail "fromPower"
fromLimit :: TachoLimit -> String
View
2  lib/Robotics/NXT/Sensor/Ultrasonic.hs
@@ -235,4 +235,4 @@ Helper function which gets all measurements available in order (closer first).
-}
usGetAllMeasurements :: InputPort -> NXT [Measurement]
usGetAllMeasurements input = mapMaybeM (usGetMeasurement input) [0..7]
- where mapMaybeM f as = catMaybes <$> (mapM f as)
+ where mapMaybeM f as = catMaybes <$> mapM f as
Please sign in to comment.
Something went wrong with that request. Please try again.