1
1
mirror of https://github.com/aelve/guide.git synced 2024-12-24 21:35:06 +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:
Guide.App
Guide.Api
Guide.Api.Methods
Guide.Api.Server
Guide.Api.Types
Guide.Main
Guide.ServerStuff
Guide.Session

View File

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

View File

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

View File

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

View File

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