1
1
mirror of https://github.com/aelve/guide.git synced 2024-12-25 22:02:58 +03:00

Fix imports (#199)

This commit is contained in:
Jens Krause 2017-09-01 22:43:55 +02:00
parent 28eb2ee6f2
commit f1fed71b13
No known key found for this signature in database
GPG Key ID: 3B2FAFBCEFA5906D
5 changed files with 15 additions and 12 deletions

View File

@ -46,6 +46,9 @@ library
exposed-modules: exposed-modules:
Guide.App Guide.App
Guide.Api Guide.Api
Guide.Api.Methods
Guide.Api.Server
Guide.Api.Types
Guide.Main Guide.Main
Guide.ServerStuff Guide.ServerStuff
Guide.Session Guide.Session

View File

@ -1,7 +1,7 @@
module Guide.Api module Guide.Api
( Guide.Api.Methods ( module Guide.Api.Methods
, Guide.Api.Server , module Guide.Api.Server
, Guide.Api.Types , module Guide.Api.Types
) where ) where
import Guide.Api.Methods import Guide.Api.Methods

View File

@ -11,23 +11,20 @@ module Guide.Api.Methods
import Imports import Imports
import Data.Aeson
import Servant import Servant
import Servant.Generic
import Network.Wai.Handler.Warp (run)
import Data.Acid as Acid import Data.Acid as Acid
import Guide.Types import Guide.Types
import Guide.State import Guide.State
import Guide.Utils (Uid) import Guide.Utils (Uid)
import Guide.Api.Types (toCategoryInfo, toCCategoryDetail) import Guide.Api.Types (ApiError(..), CategoryInfo, CCategoryDetail, toCategoryInfo, toCCategoryDetail)
getCategories :: DB -> Handler [CategoryInfo] getCategories :: DB -> Handler [CategoryInfo]
getCategories db = do getCategories db = do
liftIO (Acid.query db GetCategories) <&> \xs -> liftIO (Acid.query db GetCategories) <&> \xs ->
map toCategoryInfo xs map toCategoryInfo xs
getCategory :: DB -> Uid Category -> Handler (Either ApiError CCategory) getCategory :: DB -> Uid Category -> Handler (Either ApiError CCategoryDetail)
getCategory db catId = getCategory db catId =
liftIO (Acid.query db (GetCategoryMaybe catId)) <&> \case liftIO (Acid.query db (GetCategoryMaybe catId)) <&> \case
Nothing -> Left (ApiError "category not found") Nothing -> Left (ApiError "category not found")

View File

@ -12,15 +12,16 @@ module Guide.Api.Server
import Imports import Imports
import Data.Aeson import Data.Acid as Acid
import Servant import Servant
import Servant.Generic import Servant.Generic
import Network.Wai.Handler.Warp (run) import Network.Wai.Handler.Warp (run)
-- putStrLn that works well with concurrency -- putStrLn that works well with concurrency
import Say (say) import Say (say)
import Guide.Types
import Guide.State import Guide.State
import Guide.Api.Types (Api, Site(..))
import Guide.Api.Methods (getCategories, getCategory)
apiServer :: DB -> Site AsServer apiServer :: DB -> Site AsServer
apiServer db = Site { apiServer db = Site {

View File

@ -7,7 +7,8 @@
{-# LANGUAGE TypeOperators #-} {-# LANGUAGE TypeOperators #-}
module Guide.Api.Types module Guide.Api.Types
( ApiError(..) ( Api
, ApiError(..)
, CategoryInfo(..) , CategoryInfo(..)
, CCategoryDetail(..) , CCategoryDetail(..)
, CUid(..) , CUid(..)
@ -50,10 +51,11 @@ data Site route = Site
-- | Details of a single category (and items in it, etc) -- | Details of a single category (and items in it, etc)
, _getCategory :: route :- , _getCategory :: route :-
"category" :> Capture "id" (Uid Category) "category" :> Capture "id" (Uid Category)
:> Get '[JSON] (Either ApiError Category) :> Get '[JSON] (Either ApiError CCategoryDetail)
} }
deriving (Generic) deriving (Generic)
type Api = ToServant (Site AsApi)
---------------------------------------------------------------------------- ----------------------------------------------------------------------------
-- Client types -- Client types
---------------------------------------------------------------------------- ----------------------------------------------------------------------------