summaryrefslogtreecommitdiff
path: root/Handler/Types.hs
blob: 04055ad7d56869f78674e11ee455623441f1e304 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
module Handler.Types where

import Import

import Data.Set (Set)
import qualified Data.Set as Set

getTypesR :: Handler Value
getTypesR = returnJson <=< runDB $ do
  Set.fromList . map (kindType . entityVal) <$> selectList [] []

getTypeR :: Handler Value
getTypeR = do
  kind <- maybe (invalidArgs ["kind"]) return =<< lookupGetParam "kind"
  returnJson <=< runDB $ kindType . entityVal <$> getBy404 (UniqueKind $ normalizeKind kind)