1 {-# LANGUAGE FlexibleContexts #-}
3 {-# LANGUAGE NoMonomorphismRestriction #-}
4 {-# LANGUAGE Rank2Types #-}
5 {-# LANGUAGE ScopedTypeVariables #-}
6 {-# OPTIONS_GHC -fno-warn-missing-signatures #-}
7 module Expr.List.Test where
10 import Test.Tasty.HUnit
12 import Control.Arrow (left)
13 import Data.Proxy (Proxy(..))
14 import Data.Text (Text)
15 import Data.Type.Equality ((:~:)(Refl))
16 import Prelude hiding (mod, (==))
18 import Language.Symantic.Repr
19 import Language.Symantic.Expr
20 import Language.Symantic.Type
27 e1 = list_filter (inline $ \x -> if_ (x `mod` int 2 == int 0) t f)
28 (list $ int <$> [1..5])
34 case expr_lambda_maybe_bool_from (Proxy::Proxy IO) ast of
35 Left err -> Left err @?= snd `left` expected
36 Right (Exists_Type_and_Repr ty (Forall_Repr r)) ->
38 Left (_, err) -> Right ("…"::String) @?= Left err
39 Right (ty_expected::Type_Root_of_Expr (Expr_Lambda_List_Bool IO) h, _::h, _::Text) ->
40 (>>= (@?= (\(_::Proxy h, err) -> err) `left` expected)) $
41 case ty `type_eq` ty_expected of
42 Nothing -> return $ Left $
43 error_expr (Proxy::Proxy (Expr_Lambda_List_Bool IO)) $
44 Error_Expr_Type_mismatch ast
46 (Exists_Type ty_expected)
54 -- , (text_from_expr :: Repr_String IO h -> Text) r
58 tests = testGroup "List"
59 [{- AST "just" [AST "bool" [AST "True" []]] ==> Right
60 ( type_maybe type_bool
66 , AST "bool" [AST "True" []]
67 , AST "var" [AST "x" []]
70 ( type_maybe type_bool
72 , "just (let x0 = True in x0)" )
74 [ AST "bool" [AST "True" []]
78 , AST "not" [AST "var" [AST "x" []]]
86 , "maybe True (\\x0 -> !x0) nothing" )
88 [ AST "bool" [AST "False" []]
92 , AST "not" [AST "var" [AST "x" []]]
95 [ AST "bool" [AST "True" []]
100 , "maybe False (\\x0 -> !x0) (just True)" )