-
-
Save silky/d340c54f759ee9150734fe132ebc848a to your computer and use it in GitHub Desktop.
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 QuasiQuotes #-} | |
{-# LANGUAGE ScopedTypeVariables #-} | |
import Language.Haskell.Interpreter | |
import Text.InterpolatedString.Perl6 | |
import Control.Exception | |
import Control.Monad | |
import Data.Traversable | |
format :: Either InterpreterError Bool -> String | |
format (Left (WontCompile _) ) = " " | |
format (Left (NotAllowed _) ) = "N" | |
format (Left (UnknownError _) ) = "U" | |
format (Left (GhcException _) ) = "G" | |
format (Right True ) = "T" | |
format (Right False ) = "-" | |
test :: String -> String -> IO () | |
test r c = do | |
v <- runInterpreter $ setImports ["Prelude"] >> interpret [qc| ({r}) == ({c}) |] (as :: Bool) | |
putStr (format v) | |
pad :: String -> String | |
pad s = take (4 + (maximum (map length items))) (s ++ cycle " ") | |
main :: IO () | |
main = do | |
putStrLn legend | |
void $ for items $ \r -> do | |
putStr (pad r) | |
void $ for items $ \c -> do | |
test r c `catch` \(_ :: SomeException) -> putStr "x" | |
putStr " " | |
putStrLn "" | |
legend :: String | |
legend = [qq| | |
WontCompile = " " | |
NotAllowed = "N" | |
UnknownError = "U" | |
GhcException = "G" | |
Escaped Exception = "x" | |
Not Equal = "-" | |
Equal = "T" | |
|] | |
items :: [String] | |
items = words [qq| | |
True | |
False | |
1 | |
1.0 | |
1.3 | |
0 | |
-1 | |
"" | |
myundefinedvariable | |
"null" | |
foobar | |
NAN | |
INF | |
1.8e308 | |
"foo" | |
[] | |
"true" | |
"false" | |
"1" | |
"0" | |
"-1" | |
undefined | |
[[]] | |
[[]]::[[Bool]] | |
[0] | |
[1] | |
"12.3456789912345678" | |
"12.3456789912345670" | |
|] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment