diff --git a/Main.hs b/Main.hs index 20dd69942..7e73b00bb 100644 --- a/Main.hs +++ b/Main.hs @@ -16,17 +16,23 @@ import Network.Wai.Handler.Warp hiding (Connection) import Network.HTTP.Types.Status import qualified Data.Aeson as JSON +import Data.Aeson ((.=)) data Table = Table { viewSchema :: String , viewName :: String , viewInsertable :: Bool -} deriving (Show, Generic) +} deriving (Show) instance FromRow Table where fromRow = Table <$> field <*> field <*> fmap toBool field -instance JSON.ToJSON Table +instance JSON.ToJSON Table where + toJSON v = JSON.object [ + "schema" .= (viewSchema v), + "name" .= (viewName v), + "insertable" .= (viewInsertable v) + ] toBool :: String -> Bool toBool = (== "YES")