1 {-# LANGUAGE FlexibleContexts #-}
3 {-# LANGUAGE NoMonomorphismRestriction #-}
4 {-# LANGUAGE Rank2Types #-}
5 {-# LANGUAGE ScopedTypeVariables #-}
6 {-# LANGUAGE TypeOperators #-}
7 {-# OPTIONS_GHC -fno-warn-missing-signatures #-}
8 module Expr.List.Test where
11 import Test.Tasty.HUnit
13 import qualified Control.Arrow as Arrow
14 import qualified Control.Monad as Monad
15 import Data.Proxy (Proxy(..))
16 import Data.Text (Text)
17 import Data.Type.Equality ((:~:)(Refl))
18 import Prelude hiding (mod, (==), return)
20 import Language.Symantic.Repr
21 import Language.Symantic.Expr
22 import Language.Symantic.Type
29 e1 = list_filter (lam $ \x -> if_ (x `mod` int 2 == int 0) t f)
30 (list $ int Prelude.<$> [1..5])
39 ex_from = root_expr_from (Proxy::Proxy Ex)
44 Left err -> Left err @?= Prelude.snd `Arrow.left` expected
45 Right (Exists_Type_and_Repr ty (Forall_Repr r)) ->
47 Left (_, err) -> Right ("…"::String) @?= Left err
48 Right (ty_expected::Type_Root_of_Expr Ex h, _::h, _::Text) ->
49 (Monad.>>= (@?= (\(_::Proxy h, err) -> err) `Arrow.left` expected)) $
50 case ty `eq_type` ty_expected of
51 Nothing -> Monad.return $ Left $
52 error_expr (Proxy::Proxy Ex) $
53 Error_Expr_Type_mismatch ast
55 (Exists_Type ty_expected)
57 let h = host_from_expr r
63 -- , (text_from_expr :: Repr_Text h -> Text) r
67 tests = testGroup "List"
71 , AST "int" [AST "1" []]
72 , AST "int" [AST "2" []]
73 , AST "int" [AST "3" []]
78 , "list_reverse [1, 2, 3]" )