1 {-# LANGUAGE DataKinds #-}
2 {-# LANGUAGE NoMonomorphismRestriction #-}
3 {-# OPTIONS_GHC -fno-warn-missing-signatures #-}
4 {-# OPTIONS_GHC -O0 #-} -- speedup compile-time…
5 module Compiling.Map.Test where
9 import Data.Map.Strict (Map)
10 import qualified Data.Map.Strict as Map
11 import Data.Proxy (Proxy(..))
12 import Data.Text (Text)
13 import qualified Data.Text as Text
14 import Prelude hiding (zipWith)
16 import Language.Symantic.Typing
17 import Language.Symantic.Compiling.Bool
18 import Language.Symantic.Compiling.Map
19 import Language.Symantic.Compiling.List
20 import Language.Symantic.Compiling.Term
21 import Language.Symantic.Compiling.Tuple2
22 import Language.Symantic.Compiling.Int
23 import Language.Symantic.Compiling.Text
24 import Compiling.Term.Test
29 e1 = map_fromList $ zipWith (lam (lam . tuple2))
30 (list $ int Prelude.<$> [1..5])
31 (list $ (text . Text.singleton) Prelude.<$> ['a'..'e'])
44 (==>) = test_term_from (Proxy::Proxy Ifaces)
47 tests = testGroup "Map"
48 [ Syntax "Map.fromList"
50 [ syLam (Syntax "x" []) syInt $
51 syLam (Syntax "y" []) syText $
58 , Syntax "int" [Syntax "1" []]
59 , Syntax "int" [Syntax "2" []]
60 , Syntax "int" [Syntax "3" []]
64 , Syntax "text" [Syntax "\"a\"" []]
65 , Syntax "text" [Syntax "\"b\"" []]
66 , Syntax "text" [Syntax "\"c\"" []]
70 ( (tyMap :$ tyInt) :$ tyText
71 , Map.fromList [(1, "a"), (2, "b"), (3, "c")]
72 , "Map.fromList (((\\x0 -> (\\x1 -> zipWith (\\x2 -> (\\x3 -> (x2, x3))) x0 x1)) [1, 2, 3]) [\"a\", \"b\", \"c\"])" )
73 , Syntax "Map.foldrWithKey"
74 [ syLam (Syntax "k" []) syInt $
75 syLam (Syntax "v" []) syText $
76 syLam (Syntax "a" []) (syTuple2 [syInt, syText]) $
80 , Syntax "fst" [ Syntax "a" [] ]
84 , Syntax "snd" [ Syntax "a" [] ]
88 [ Syntax "int" [Syntax "0" []]
89 , Syntax "text" [Syntax "\"\"" []]
91 , Syntax "Map.fromList"
93 [ syLam (Syntax "x" []) syInt $
94 syLam (Syntax "y" []) syText $
101 , Syntax "int" [Syntax "1" []]
102 , Syntax "int" [Syntax "2" []]
103 , Syntax "int" [Syntax "3" []]
107 , Syntax "text" [Syntax "\"a\"" []]
108 , Syntax "text" [Syntax "\"b\"" []]
109 , Syntax "text" [Syntax "\"c\"" []]
114 ( (tyTuple2 :$ tyInt) :$ tyText
116 , "((\\x0 -> (\\x1 -> Map.foldrWithKey (\\x2 -> (\\x3 -> (\\x4 -> ((\\x5 -> x2 + x5) (fst x4), (\\x5 -> mappend x3 x5) (snd x4))))) x0 x1)) (0, \"\")) (Map.fromList (((\\x0 -> (\\x1 -> zipWith (\\x2 -> (\\x3 -> (x2, x3))) x0 x1)) [1, 2, 3]) [\"a\", \"b\", \"c\"]))" )