Skip to content

Commit

Permalink
GHC 7.4 compatibility. Version bump.
Browse files Browse the repository at this point in the history
  • Loading branch information
mitar committed Aug 5, 2012
1 parent 7f2fb13 commit 96be2f0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
12 changes: 6 additions & 6 deletions NXT.cabal
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Name: NXT
Version: 0.2.1
Version: 0.2.2
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
Expand All @@ -16,7 +16,7 @@ License: LGPL-3
License-file: LICENSE
Author: Mitar Milutinovic
Maintainer: mitar.haskell@tnode.com
Copyright: (c) 2011 Mitar Milutinovic
Copyright: (c) 2011-2012 Mitar Milutinovic
Category: Robotics
Build-type: Simple
Cabal-version: >= 1.10
Expand Down Expand Up @@ -69,7 +69,7 @@ Executable nxt-shutdown
HS-source-dirs: src
Build-depends: base >= 4.3 && < 5,
mtl >= 1.1 && < 3,
NXT == 0.2.1
NXT == 0.2.2
GHC-options: -Wall
Default-language: Haskell2010

Expand All @@ -78,7 +78,7 @@ Executable nxt-status
HS-source-dirs: src
Build-depends: base >= 4.3 && < 5,
mtl >= 1.1 && < 3,
NXT == 0.2.1
NXT == 0.2.2
GHC-options: -Wall
Default-language: Haskell2010

Expand All @@ -89,7 +89,7 @@ Executable nxt-upload
mtl >= 1.1 && < 3,
bytestring >= 0.9 && < 1,
filepath >= 1.1 && < 2,
NXT == 0.2.1
NXT == 0.2.2
GHC-options: -Wall
Default-language: Haskell2010

Expand All @@ -106,7 +106,7 @@ Test-suite nxt-tests
time >= 1.2 && < 2,
bytestring >= 0.9 && < 1.0,
filepath >= 1.2 && < 2,
NXT == 0.2.1
NXT == 0.2.2
GHC-options: -Wall -rtsopts
Default-language: Haskell2010
HS-source-dirs: tests
Expand Down
12 changes: 6 additions & 6 deletions lib/Robotics/NXT/Data.hs
Original file line number Diff line number Diff line change
Expand Up @@ -74,30 +74,30 @@ intToData x = unfoldr getByte x
where getByte 0x00 = Nothing
getByte y = Just (fromIntegral $ y `mod` 0x100, y `div` 0x100)

toUByte :: Integral a => a -> [Word8] -- one byte, unsigned
toUByte :: (Show a, Integral a) => a -> [Word8] -- one byte, unsigned
toUByte x | x >= 0x00 && x <= 0xFF = intToData x
| otherwise = throw . PatternMatchFail $ "toUByte: " ++ show x

toUWord :: Integral a => a -> [Word8] -- two bytes, unsigned, least significant byte first
toUWord :: (Show a, Integral a) => a -> [Word8] -- two bytes, unsigned, least significant byte first
toUWord x | x >= 0x00 && x <= 0xFFFF = take 2 . flip (++) (repeat 0x00) . intToData $ x
| otherwise = throw . PatternMatchFail $ "toUWord: " ++ show x

toULong :: Integral a => a -> [Word8] -- four bytes, unsigned, least significant byte first
toULong :: (Show a, Integral a) => a -> [Word8] -- four bytes, unsigned, least significant byte first
toULong x | x' >= 0x00 && x' <= 0xFFFFFFFF = take 4 . flip (++) (repeat 0x00) . intToData $ x'
| otherwise = throw . PatternMatchFail $ "toULong: " ++ show x
where x' = fromIntegral x :: Integer

toSByte :: Integral a => a -> [Word8] -- one byte, signed
toSByte :: (Show a, Integral a) => a -> [Word8] -- one byte, signed
toSByte x | x >= (-0x80) && x < 0x00 = intToData $ 0x100 + x
| x >= 0x00 && x <= 0x7F = intToData x
| otherwise = throw . PatternMatchFail $ "toSByte: " ++ show x

toSWord :: Integral a => a -> [Word8] -- two bytes, signed, least significant byte first
toSWord :: (Show a, Integral a) => a -> [Word8] -- two bytes, signed, least significant byte first
toSWord x | x >= (-0x8000) && x < 0x00 = take 2 . flip (++) (repeat 0x00) . intToData $ 0x10000 + x
| x >= 0x00 && x <= 0x7FFF = take 2 . flip (++) (repeat 0x00) . intToData $ x
| otherwise = throw . PatternMatchFail $ "toSWord: " ++ show x

toSLong :: Integral a => a -> [Word8] -- four bytes, signed, least significant byte first
toSLong :: (Show a, Integral a) => a -> [Word8] -- four bytes, signed, least significant byte first
toSLong x | x' >= (-0x80000000) && x' < 0x00 = take 4 . flip (++) (repeat 0x00) . intToData $ 0x100000000 + x'
| x' >= 0x00 && x' <= 0x7FFFFFFF = take 4 . flip (++) (repeat 0x00) . intToData $ x'
| otherwise = throw . PatternMatchFail $ "toSLong: " ++ show x
Expand Down

0 comments on commit 96be2f0

Please sign in to comment.