1 {-# LANGUAGE NoMonomorphismRestriction #-}
2 {-# LANGUAGE UndecidableInstances #-}
3 {-# OPTIONS_GHC -fno-warn-orphans #-}
4 {-# OPTIONS_GHC -fno-warn-missing-signatures #-}
5 module Compiling.Functor.Test where
9 import Data.Proxy (Proxy(..))
10 import Data.Text (Text)
11 import Prelude hiding ((&&), not, (||))
13 import Language.Symantic.Parsing
14 import Language.Symantic.Typing
15 import Language.Symantic.Compiling
16 import Compiling.Term.Test
17 import Compiling.Bool.Test ()
27 (==>) = test_term_from (Proxy::Proxy Ifaces)
30 ( Inj_Token (Syntax Text) ts Functor
31 , Tokenize (Syntax Text) (Syntax Text) ts ) =>
32 TokenizeT (Syntax Text) (Syntax Text) ts (Proxy Functor) where
33 tokenizeT _t (Syntax "fmap" (ast_f : ast_m : as)) = Just $ do
36 Right $ (as,) $ EToken $ inj_token (Syntax "fmap" [ast_f, ast_m]) $
37 Token_Term_Functor_fmap f m
38 tokenizeT _t (Syntax "(<$)" (ast_a : ast_fb : as)) = Just $ do
41 Right $ (as,) $ EToken $ inj_token (Syntax "fmap" [ast_a, ast_fb]) $
42 Token_Term_Functor_ltdollar a fb
43 tokenizeT _t _sy = Nothing
46 tests = testGroup "Functor"
48 [ syLam "x" (sy @Bool)
49 (Syntax "not" [syVar "x"])
50 , Syntax "Just" [syLit True]
51 ] ==> Right (ty @Maybe :$ ty @Bool, Just False, "fmap (\\x0 -> (\\x1 -> not x1) x0) (Just True)")
54 , Syntax "Just" [syLit True]
55 ] ==> Right (ty @Maybe :$ ty @Bool, Just False, "False <$ Just True")