From 3cd4169e33c07b71129aafcecfb81a3b5007fa39 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Wed, 15 Mar 2017 18:11:47 +0100 Subject: Autocomplete types --- Handler/Types.hs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 Handler/Types.hs (limited to 'Handler/Types.hs') diff --git a/Handler/Types.hs b/Handler/Types.hs new file mode 100644 index 0000000..04055ad --- /dev/null +++ b/Handler/Types.hs @@ -0,0 +1,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) -- cgit v1.2.3