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
11 import Test.Tasty.HUnit
13 import Control.Arrow (left)
14 import Data.Proxy (Proxy(..))
15 import Data.Text (Text)
16 import Data.Type.Equality ((:~:)(Refl))
18 import Prelude hiding (mod, (==))
20 import Language.Symantic.Repr
21 import Language.Symantic.Expr
22 import Language.Symantic.Type
29 e1 = list_filter (inline $ \x -> if_ (x `mod` int 2 == int 0) t f)
30 (list $ int <$> [1..5])
36 case ex_from (Proxy::Proxy IO) ast of
37 Left err -> Left err @?= snd `left` expected
38 Right (Exists_Type_and_Repr ty (Forall_Repr r)) ->
40 Left (_, err) -> Right ("…"::String) @?= Left err
41 Right (ty_expected::Type_Root_of_Expr (Ex IO) h, _::h, _::Text) ->
42 (>>= (@?= (\(_::Proxy h, err) -> err) `left` expected)) $
43 case ty `eq_type` ty_expected of
44 Nothing -> return $ Left $
45 error_expr (Proxy::Proxy (Ex IO)) $
46 Error_Expr_Type_mismatch ast
48 (Exists_Type ty_expected)
56 -- , (text_from_expr :: Repr_String IO h -> Text) r
60 tests = testGroup "List"
61 [{- AST "just" [AST "bool" [AST "True" []]] ==> Right
62 ( type_maybe type_bool
68 , AST "bool" [AST "True" []]
69 , AST "var" [AST "x" []]
72 ( type_maybe type_bool
74 , "just (let x0 = True in x0)" )
76 [ AST "bool" [AST "True" []]
80 , AST "not" [AST "var" [AST "x" []]]
88 , "maybe True (\\x0 -> !x0) nothing" )
90 [ AST "bool" [AST "False" []]
94 , AST "not" [AST "var" [AST "x" []]]
97 [ AST "bool" [AST "True" []]
102 , "maybe False (\\x0 -> !x0) (just True)" )