1- {-# LANGUAGE DeriveFunctor #-}
21{-# LANGUAGE FlexibleInstances #-}
3- {-# LANGUAGE PartialTypeSignatures #-}
4- {-# LANGUAGE LambdaCase #-}
52{-# LANGUAGE MultiParamTypeClasses #-}
3+ {-# LANGUAGE PartialTypeSignatures #-}
64{-# LANGUAGE ScopedTypeVariables #-}
75
86module Main where
97
108import Common
119import Control.Comonad.Cofree (Cofree ((:<) ))
1210import Data.Bifunctor (second )
11+ import Data.Ratio
1312import PrettyPrint
1413import qualified System.IO.Strict as Strict
1514import Telomare
16- import Telomare.Eval (compileUnitTest , EvalError (CompileConversionError ))
17- import Telomare.RunTime (simpleEval )
15+ import Telomare.Eval (EvalError (CompileConversionError ), compileUnitTest )
16+ import Telomare.Parser (AnnotatedUPT , TelomareParser , parseLongExpr ,
17+ parsePrelude )
1818import Telomare.Resolver (process )
19- import Telomare.Parser ( parseLongExpr , TelomareParser , parsePrelude , AnnotatedUPT )
19+ import Telomare.RunTime ( simpleEval )
2020import Test.Tasty
2121import Test.Tasty.HUnit
2222import Test.Tasty.QuickCheck as QC
23- import Text.Megaparsec (runParser , errorBundlePretty , eof )
24- import Data.Ratio
23+ import Text.Megaparsec (eof , errorBundlePretty , runParser )
2524
2625main :: IO ()
2726main = defaultMain tests
@@ -49,7 +48,7 @@ loadPreludeBindings :: IO [(String, UnprocessedParsedTerm)]
4948loadPreludeBindings = do
5049 preludeResult <- Strict. readFile " Prelude.tel"
5150 case parsePrelude preludeResult of
52- Left _ -> pure []
51+ Left _ -> pure []
5352 Right bs -> pure $ fmap (second forget) bs
5453
5554evalExprString :: String -> IO (Either String String )
@@ -59,11 +58,11 @@ evalExprString input = do
5958 case parseResult of
6059 Left err -> pure $ Left (errorBundlePretty err)
6160 Right exprBindings -> do
62- let allBindingsUPT = preludeBindings ++ exprBindings
61+ let allBindingsUPT = preludeBindings <> exprBindings
6362 allBindings :: [(String , Cofree UnprocessedParsedTermF LocTag )]
6463 allBindings = fmap (second (tag DummyLoc )) allBindingsUPT
6564 uptMaybe = lookup " _tmp_" allBindings
66- termMaybe = fmap (DummyLoc :< ) . fmap ( LetUPF allBindings) $ uptMaybe
65+ termMaybe = fmap (( DummyLoc :< ) . LetUPF allBindings) uptMaybe
6766 compiled = compileUnitTest =<< maybeToRight (termMaybe >>= rightToMaybe . process)
6867 case compiled of
6968 Left err -> pure $ Left (show err)
@@ -75,7 +74,7 @@ assertExpr :: String -> String -> Assertion
7574assertExpr input expected = do
7675 res <- evalExprString input
7776 case res of
78- Left err -> assertFailure $ " Evaluation failed: " <> err
77+ Left err -> assertFailure $ " Evaluation failed: " <> err
7978 Right val -> val @?= expected
8079
8180rationalToString :: Ratio Integer -> String
@@ -121,9 +120,9 @@ unitTestsRatArithmetic = testGroup "Unit tests on natural arithmetic expresions"
121120---------------------
122121
123122qcPropsNatArithmetic = testGroup " Property tests on natural arithmetic expressions (QuickCheck)"
124- [
123+ [
125124 ]
126125
127126qcPropsRatArithmetic = testGroup " Property tests on rational arithmetic expressions (QuickCheck)"
128- [
127+ [
129128 ]
0 commit comments