Skip to content

Instantly share code, notes, and snippets.

@aiya000
Last active January 27, 2017 10:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aiya000/c5d93cd1e529163f1eb1bda9e3699632 to your computer and use it in GitHub Desktop.
Save aiya000/c5d93cd1e529163f1eb1bda9e3699632 to your computer and use it in GitHub Desktop.
HaskellのRank2Typesがだいぶわかるやつ ref: http://qiita.com/aiya000/items/2d05df630635f345f607
{-# LANGUAGE ExistentialQuantification #-}
{-# LANGUAGE Rank2Types #-}
import Data.String (IsString)
import Data.Text (Text)
import Shelly (run_)
import System.EasyFile (doesFileExist)
type FilePath' = forall s. IsString s => s
flagFile :: FilePath'
flagFile = "/tmp/flag"
-- ここに、shellyを使ったほうがいい事情があるとします。
-- 故にshelly使います (※)
createFlagFile :: IO ()
createFlagFile = shelly $ run_ "rm" ["-f", flagFile]
flagFileExists :: IO Bool
flagFileExists = doesFileExist flagFile
type FilePath' = forall s. IsStrings s => s
g :: (a -> a) -> (Bool, Char)
g f = (f True, f 'a')
g :: (forall a. a -> a) -> (Bool, Char)
g f = (f True, f 'a')
type FilePath' = forall s. IsString s => s
flagFile :: FilePath'
flagFile = "/tmp/flag"
-- 1
createFlagFile :: IO ()
createFlagFile = shelly $ run_ "rm" ["-f", flagFile]
-- 2
flagFileExists :: IO Bool
flagFileExists = doesFileExist flagFile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment