git.iko.soy/purescript-indexed-DB
on master help sign in
make use of the purescript-read lib instead of FromString class
commit54bcd27d7b611049e00610c0693e659a1dad6352 authorKtorZ <matthias.benkort@gmail.com> dateThu 27 Jul 2017, 23:37 (9 years ago) parent86207ad
3 files changed+16−16
bower.json+6−2 src/Database/IndexedDB/Core.purs+6−11 src/Database/IndexedDB/IDBCursor.purs+4−3
bower.json+6−2
@@ -25,9 +25,13 @@
2525 "url": "git://github.com/truqu/purescript-indexedDB.git"
2626 },
2727 "dependencies": {
28− "purescript-maybe": "^3.0.0",
2928 "purescript-aff": "^3.1.0",
30− "purescript-datetime": "^3.2.0"
29+ "purescript-datetime": "^3.2.0",
30+ "purescript-eff": "^3.1.0",
31+ "purescript-exceptions": "https://github.com/truqu/purescript-exceptions.git#3.1.0",
32+ "purescript-maybe": "^3.0.0",
33+ "purescript-prelude": "^3.1.0",
34+ "purescript-read": "^1.0.0"
3135 },
3236 "devDependencies": {
3337 "purescript-spec": "^1.0.0",
src/Database/IndexedDB/Core.purs+6−11
@@ -8,8 +8,7 @@
88-- | by the API.
99
1010module Database.IndexedDB.Core
11− ( class FromString, parse
12− , IDB
11+ ( IDB
1312 , CursorDirection(..)
1413 , CursorSource(..)
1514 , Database
@@ -28,6 +27,7 @@ import Prelude (class Show)
2827
2928import Control.Monad.Eff (kind Effect)
3029import Data.Maybe (Maybe(..))
30+import Data.String.Read (class Read)
3131
3232import Database.IndexedDB.IDBKey
3333
@@ -109,11 +109,6 @@ foreign import data Transaction :: Type
109109foreign import data ValueCursor :: Type
110110
111111
112−-- | FromString represents enumerations that can be represented as Strings.
113−class FromString a where
114− parse :: String -> Maybe a
115−
116−
117112foreign import _showCursor :: forall cursor. cursor -> String
118113instance showKeyCursor :: Show KeyCursor where
119114 show = _showCursor
@@ -175,8 +170,8 @@ instance showTransactionMode :: Show TransactionMode where
175170 VersionChange -> "versionchange"
176171
177172
178−instance fromStringCursorDirection :: FromString CursorDirection where
179− parse s =
173+instance readCursorDirection :: Read CursorDirection where
174+ read s =
180175 case s of
181176 "next" -> Just Next
182177 "nextunique" -> Just NextUnique
@@ -185,8 +180,8 @@ instance fromStringCursorDirection :: FromString CursorDirection where
185180 _ -> Nothing
186181
187182
188−instance fromStringTransactionMode :: FromString TransactionMode where
189− parse s =
183+instance readTransactionMode :: Read TransactionMode where
184+ read s =
190185 case s of
191186 "readonly" -> Just ReadOnly
192187 "readwrite" -> Just ReadWrite
src/Database/IndexedDB/IDBCursor.purs+4−3
@@ -16,11 +16,12 @@ module Database.IndexedDB.IDBCursor
1616import Prelude (Unit, ($), (>>>), map)
1717
1818import Control.Monad.Aff (Aff)
19+import Data.Foreign (Foreign, toForeign, unsafeFromForeign)
1920import Data.Function.Uncurried as Fn
2021import Data.Function.Uncurried (Fn2, Fn3)
2122import Data.Maybe (Maybe)
2223import Data.Nullable (Nullable, toNullable)
23−import Data.Foreign (Foreign, toForeign, unsafeFromForeign)
24+import Data.String.Read (read)
2425
2526import Database.IndexedDB.Core
2627import Database.IndexedDB.IDBKey.Internal (class IDBKey, Key(..), toKey, extractForeign)
@@ -80,7 +81,7 @@ direction'
8081 :: KeyCursor
8182 -> CursorDirection
8283direction' =
83− Fn.runFn2 _direction (parse >>> toNullable)
84+ Fn.runFn2 _direction (read >>> toNullable)
8485
8586
8687-- | Returns the key of the cursor. Throws a "InvalidStateError" DOMException
@@ -122,7 +123,7 @@ direction
122123 :: ValueCursor
123124 -> CursorDirection
124125direction =
125− Fn.runFn2 _direction (parse >>> toNullable)
126+ Fn.runFn2 _direction (read >>> toNullable)
126127
127128
128129-- | Returns the key of the cursor. Throws a "InvalidStateError" DOMException