Permalink
Browse files

Do not use fromString, prefer pack

  • Loading branch information...
dzhus committed Apr 22, 2012
1 parent d532143 commit c9e9d751301f08de635c5aaf19a7e2815795233d
View
@@ -73,6 +73,5 @@ library
snap-core == 0.8.*,
snaplet-redis == 0.1.*,
text == 0.11.*,
- utf8-string == 0.3.*,
websockets == 0.6.*,
websockets-snap == 0.6.*
@@ -31,10 +31,9 @@ import Data.Functor
import Data.Maybe
import Data.Char
-import qualified Data.ByteString as B
+import qualified Data.ByteString.Char8 as B
import qualified Data.Text as T
import qualified Data.Text.Encoding as E
-import qualified Data.ByteString.UTF8 as BU (fromString)
import qualified Data.Map as M
import Database.Redis
@@ -51,15 +50,6 @@ instanceKey :: ModelName -> InstanceId -> B.ByteString
instanceKey model id = B.concat [model, ":", id]
-------------------------------------------------------------------------------
--- | Cut instance model and id from Redis key
---
--- >>> keyToId "case:32198"
--- 32198
-keyToId :: B.ByteString -> InstanceId
-keyToId key = B.tail $ B.dropWhile (/= 0x3a) key
-
-
------------------------------------------------------------------------------
-- | Get Redis key which stores id counter for model
modelIdKey :: ModelName -> B.ByteString
@@ -164,7 +154,7 @@ create :: ModelName -- ^ Model name
create mname commit findices = do
-- Take id from global:model:id
Right n <- incr $ modelIdKey mname
- newId <- return $ (BU.fromString . show) n
+ newId <- return $ (B.pack . show) n
-- Save new instance
_ <- hmset (instanceKey mname newId) (M.toList commit)
@@ -20,7 +20,7 @@ import Data.Aeson as A
import Data.Functor
-import qualified Data.ByteString.UTF8 as BU (fromString)
+import qualified Data.ByteString.Char8 as B
import qualified Data.ByteString.Lazy as LB (readFile)
import qualified Data.Map as M
@@ -56,7 +56,7 @@ loadModel modelFile groups
-- | Build metamodel name from its file path.
pathToModelName :: FilePath -> ModelName
-pathToModelName filepath = BU.fromString $ takeBaseName filepath
+pathToModelName filepath = B.pack $ takeBaseName filepath
-- | Read all models from directory to a map.

0 comments on commit c9e9d75

Please sign in to comment.