Last active
January 27, 2017 10:58
-
-
Save aiya000/c5d93cd1e529163f1eb1bda9e3699632 to your computer and use it in GitHub Desktop.
HaskellのRank2Typesがだいぶわかるやつ ref: http://qiita.com/aiya000/items/2d05df630635f345f607
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type FilePath' = forall s. IsStrings s => s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
g :: (a -> a) -> (Bool, Char) | |
g f = (f True, f 'a') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
g :: (forall a. a -> a) -> (Bool, Char) | |
g f = (f True, f 'a') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type FilePath' = forall s. IsString s => s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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