keycode 0.1.1 → 0.2
raw patch · 4 files changed
+68/−14 lines, 4 filesdep +ghc-primdep +template-haskellPVP ok
version bump matches the API change (PVP)
Dependencies added: ghc-prim, template-haskell
API changes (from Hackage documentation)
- Web.KeyCode: instance Bounded Key
- Web.KeyCode: instance Enum Key
- Web.KeyCode: instance Eq Key
- Web.KeyCode: instance Ix Key
- Web.KeyCode: instance Ord Key
- Web.KeyCode: instance Read Key
- Web.KeyCode: instance Show Key
+ Web.KeyCode: instance Data.Data.Data Web.KeyCode.Key
+ Web.KeyCode: instance GHC.Arr.Ix Web.KeyCode.Key
+ Web.KeyCode: instance GHC.Classes.Eq Web.KeyCode.Key
+ Web.KeyCode: instance GHC.Classes.Ord Web.KeyCode.Key
+ Web.KeyCode: instance GHC.Enum.Bounded Web.KeyCode.Key
+ Web.KeyCode: instance GHC.Enum.Enum Web.KeyCode.Key
+ Web.KeyCode: instance GHC.Generics.Generic Web.KeyCode.Key
+ Web.KeyCode: instance GHC.Read.Read Web.KeyCode.Key
+ Web.KeyCode: instance GHC.Show.Show Web.KeyCode.Key
+ Web.KeyCode: instance Language.Haskell.TH.Syntax.Lift Web.KeyCode.Key
Files
- CHANGELOG.md +5/−2
- LICENSE +1/−1
- keycode.cabal +14/−4
- src/Web/KeyCode.hs +48/−7
CHANGELOG.md view
@@ -1,5 +1,8 @@-# 0.1.1+## 0.2+* Add `Data`, `Typeable`, `Generic`, and `Lift` instances for `Key` when possible++### 0.1.1 * Bugfix involving keycode 74 (should be J, was incorrectly giving K) [roboguy13] -# 0.1+## 0.1 * Initial commit
LICENSE view
@@ -1,4 +1,4 @@-Copyright (c) 2015, Ryan Scott+Copyright (c) 2015-2016, Ryan Scott All rights reserved.
keycode.cabal view
@@ -1,5 +1,5 @@ name: keycode-version: 0.1.1+version: 0.2 synopsis: Maps web browser keycodes to their corresponding keyboard keys description: Keyboard events in web browsers are often represented as keycodes, which (1) are difficult to remember, and (2) sometimes vary from@@ -11,12 +11,19 @@ license: BSD3 license-file: LICENSE author: Ryan Scott-maintainer: Ryan Scott <ryan.gl.scott@ku.edu>-copyright: (C) 2015 Ryan Scott+maintainer: Ryan Scott <ryan.gl.scott@gmail.com>+copyright: (C) 2015-2016 Ryan Scott stability: Experimental category: Web build-type: Simple extra-source-files: CHANGELOG.md, README.md+tested-with: GHC == 7.0.4+ , GHC == 7.2.2+ , GHC == 7.4.2+ , GHC == 7.6.3+ , GHC == 7.8.4+ , GHC == 7.10.3+ , GHC == 8.0.1 cabal-version: >=1.10 source-repository head@@ -25,8 +32,11 @@ library exposed-modules: Web.KeyCode- build-depends: base >= 3 && < 5+ build-depends: base >= 3 && < 5 , containers+ , ghc-prim+ if impl(ghc >= 8.0)+ build-depends: template-haskell >= 2.11 && < 2.12 hs-source-dirs: src default-language: Haskell98 ghc-options: -Wall
src/Web/KeyCode.hs view
@@ -1,6 +1,20 @@+{-# LANGUAGE CPP #-}++#if __GLASGOW_HASKELL__ >= 700+{-# LANGUAGE DeriveDataTypeable #-}+#endif++#if __GLASGOW_HASKELL__ >= 702+{-# LANGUAGE DeriveGeneric #-}+#endif++#if __GLASGOW_HASKELL__ >= 800+{-# LANGUAGE DeriveLift #-}+#endif+ {-| Module: Web.KeyCode-Copyright: (C) 2015 Ryan Scott+Copyright: (C) 2015-2016 Ryan Scott License: BSD-style (see the file LICENSE) Maintainer: Ryan Scott Stability: Experimental@@ -18,10 +32,20 @@ import Data.IntMap (IntMap, findWithDefault, fromAscList) import Data.Ix (Ix) +#if __GLASGOW_HASKELL__ >= 700+import Data.Data (Data, Typeable)+#endif+#if __GLASGOW_HASKELL__ >= 702+import GHC.Generics (Generic)+#endif+#if __GLASGOW_HASKELL__ >= 800+import Language.Haskell.TH.Syntax (Lift)+#endif+ -- | A numeric code representing the value of a pressed 'Key'. Note that a particular -- 'Key' may not uniquely map to a particular 'KeyCode', as the implementation of -- key codes is browser-dependent.--- +-- -- /Since: 0.1/ type KeyCode = Int @@ -29,10 +53,10 @@ -- particular key have the same 'KeyCode', so there are not separate constructors for -- them. There is also an 'UnknownKey' constructor for keys without a particular -- 'KeyCode'.--- +-- -- Note that the 'Enum' instance does not correspond to the 'KeyCode's, but is simply -- provided for convenience.--- +-- -- /Since: 0.1/ data Key = Backspace | Tab@@ -134,17 +158,34 @@ | BracketRight -- ^ Without Shift: @]@. With Shift: @}@. | Apostrophe -- ^ Without Shift: @\'@. With Shift: @"@. | UnknownKey- deriving (Bounded, Enum, Eq, Ix, Ord, Read, Show)+ deriving ( Bounded+ , Enum+ , Eq+ , Ix+ , Ord+ , Read+ , Show+#if __GLASGOW_HASKELL__ >= 700+ , Data+ , Typeable+#endif+#if __GLASGOW_HASKELL__ >= 702+ , Generic+#endif+#if __GLASGOW_HASKELL__ >= 800+ , Lift+#endif+ ) -- | Determine the 'Key' that a 'KeyCode' represents. If one cannot be found, -- 'UnknownKey' is returned.--- +-- -- /Since: 0.1/ keyCodeLookup :: KeyCode -> Key keyCodeLookup key = findWithDefault UnknownKey key keyCodeMap -- | An map of known 'KeyCode's to 'Key's.--- +-- -- /Since: 0.1/ keyCodeMap :: IntMap Key keyCodeMap = fromAscList [