eidolon/Helper.hs

37 lines
769 B
Haskell
Raw Normal View History

2014-08-13 22:52:57 +00:00
module Helper
( getUserIdFromText
2014-08-14 00:25:18 +00:00
, extractKey
2014-08-15 11:24:14 +00:00
-- , getUserName
2014-08-13 22:52:57 +00:00
)
where
import Prelude
2014-08-15 11:24:14 +00:00
import Model
import Control.Applicative
import Control.Monad.Trans.Class
2014-08-13 22:52:57 +00:00
import Data.Text
2014-08-15 11:24:14 +00:00
import Data.Maybe
import Database.Persist
2014-08-13 22:52:57 +00:00
import Database.Persist.Types
2014-08-15 11:24:14 +00:00
import System.FilePath
import Yesod.Persist.Core
import Yesod.Core.Types
2014-08-13 22:52:57 +00:00
2014-08-15 11:24:14 +00:00
getUserIdFromText :: Text -> UserId
2014-08-13 22:52:57 +00:00
getUserIdFromText tempUserId =
PersistInt64 $ fromIntegral $ read $ unpack tempUserId
2014-08-14 00:25:18 +00:00
extractKey :: KeyBackend backend entity -> Text
extractKey = extractKey' . unKey
where
extractKey' (PersistInt64 k) = pack $ show k
extractKey' _ = ""
2014-08-15 11:24:14 +00:00
--getUserName :: Text -> User
--getUserName textId =
-- let
-- userId = getUserIdFromText textId
-- user = get $ userId
-- in
-- show user