File: Util.hs

package info (click to toggle)
haskell-persistent 0.9.0.4-2
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 200 kB
  • sloc: haskell: 2,270; makefile: 3
file content (19 lines) | stat: -rw-r--r-- 448 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
{-# LANGUAGE OverloadedStrings #-}
module Database.Persist.Util
    ( nullable
    , deprecate
    ) where

import System.IO.Unsafe (unsafePerformIO)
import Data.Text

nullable :: [Text] -> Bool
nullable s
    | "Maybe" `elem` s = True
    | "null" `elem` s = deprecate "Please replace null with Maybe" True
    | otherwise = False

deprecate :: String -> a -> a
deprecate s x = unsafePerformIO $ do
    putStrLn $ "DEPRECATED: " ++ s
    return x