1 {-# LANGUAGE FlexibleContexts #-}
3 {-# LANGUAGE NoMonomorphismRestriction #-}
4 {-# LANGUAGE ScopedTypeVariables #-}
5 {-# LANGUAGE TypeOperators #-}
6 {-# OPTIONS_GHC -fno-warn-missing-signatures #-}
8 module Expr.Functor.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 ((&&), not, (||), (==), fmap, (+))
20 import Language.Symantic.Type
21 import Language.Symantic.Expr as Expr
22 import Language.Symantic.Repr
29 e1 = fmap (lam $ \x -> x + int 1) (list $ int Prelude.<$> [1..3])
42 ex_from = root_expr_from (Proxy::Proxy Ex)
47 Left err -> Left err @?= Prelude.snd `Arrow.left` expected
48 Right (Exists_Type0_and_Repr ty (Forall_Repr r)) ->
50 Left (_, err) -> Right ("…"::String) @?= Left err
51 Right (ty_expected::Type_Root_of_Expr Ex h, _::h, _::Text) ->
52 (Monad.>>= (@?= (\(_::Proxy h, err) -> err) `Arrow.left` expected)) $
53 case ty `type0_eq` ty_expected of
54 Nothing -> Monad.return $ Left $
55 error_expr (Proxy::Proxy Ex) $
56 Error_Expr_Type_mismatch ast
58 (Exists_Type0 ty_expected)
60 let h = host_from_expr r
66 -- , (text_from_expr :: Repr_Text h -> Text) r
70 tests = testGroup "Functor"
75 , AST "+" [ AST "var" [AST "x" []]
76 , AST "int" [AST "1" []] ]
80 , AST "int" [AST "1" []]
81 , AST "int" [AST "2" []]
82 , AST "int" [AST "3" []]
87 , "fmap (\\x0 -> x0 + 1) [1, 2, 3]" )