diff options
author | Gregor Kleen <gkleen@yggdrasil.li> | 2017-03-15 18:11:47 +0100 |
---|---|---|
committer | Gregor Kleen <gkleen@yggdrasil.li> | 2017-03-15 18:11:47 +0100 |
commit | 3cd4169e33c07b71129aafcecfb81a3b5007fa39 (patch) | |
tree | 261de0303273cc1a861977dc9aebce235d0afe51 /Handler/Types.hs | |
parent | 37f0dac79707a0de81ec6364d2704007eefd9289 (diff) | |
download | bar-3cd4169e33c07b71129aafcecfb81a3b5007fa39.tar bar-3cd4169e33c07b71129aafcecfb81a3b5007fa39.tar.gz bar-3cd4169e33c07b71129aafcecfb81a3b5007fa39.tar.bz2 bar-3cd4169e33c07b71129aafcecfb81a3b5007fa39.tar.xz bar-3cd4169e33c07b71129aafcecfb81a3b5007fa39.zip |
Autocomplete types
Diffstat (limited to 'Handler/Types.hs')
-rw-r--r-- | Handler/Types.hs | 15 |
1 files changed, 15 insertions, 0 deletions
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 @@ | |||
1 | module Handler.Types where | ||
2 | |||
3 | import Import | ||
4 | |||
5 | import Data.Set (Set) | ||
6 | import qualified Data.Set as Set | ||
7 | |||
8 | getTypesR :: Handler Value | ||
9 | getTypesR = returnJson <=< runDB $ do | ||
10 | Set.fromList . map (kindType . entityVal) <$> selectList [] [] | ||
11 | |||
12 | getTypeR :: Handler Value | ||
13 | getTypeR = do | ||
14 | kind <- maybe (invalidArgs ["kind"]) return =<< lookupGetParam "kind" | ||
15 | returnJson <=< runDB $ kindType . entityVal <$> getBy404 (UniqueKind $ normalizeKind kind) | ||