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
18 import Compiling.Term.Test
23 e1 = map_fromList $ zipWith (lam (lam . tuple2))
24 (list $ int Prelude.<$> [1..5])
25 (list $ (text . Text.singleton) Prelude.<$> ['a'..'e'])
38 (==>) = test_term_from (Proxy::Proxy Ifaces)
41 tests = testGroup "Map"
42 [ Syntax "Map.fromList"
44 [ syLam (Syntax "x" []) syInt $
45 syLam (Syntax "y" []) syText $
52 , Syntax "int" [Syntax "1" []]
53 , Syntax "int" [Syntax "2" []]
54 , Syntax "int" [Syntax "3" []]
58 , Syntax "text" [Syntax "\"a\"" []]
59 , Syntax "text" [Syntax "\"b\"" []]
60 , Syntax "text" [Syntax "\"c\"" []]
64 ( (tyMap :$ tyInt) :$ tyText
65 , Map.fromList [(1, "a"), (2, "b"), (3, "c")]
66 , "Map.fromList (((\\x0 -> (\\x1 -> zipWith (\\x2 -> (\\x3 -> (x2, x3))) x0 x1)) [1, 2, 3]) [\"a\", \"b\", \"c\"])" )
67 , Syntax "Map.foldrWithKey"
68 [ syLam (Syntax "k" []) syInt $
69 syLam (Syntax "v" []) syText $
70 syLam (Syntax "a" []) (syTuple2 [syInt, syText]) $
74 , Syntax "fst" [ Syntax "a" [] ]
78 , Syntax "snd" [ Syntax "a" [] ]
82 [ Syntax "int" [Syntax "0" []]
83 , Syntax "text" [Syntax "\"\"" []]
85 , Syntax "Map.fromList"
87 [ syLam (Syntax "x" []) syInt $
88 syLam (Syntax "y" []) syText $
95 , Syntax "int" [Syntax "1" []]
96 , Syntax "int" [Syntax "2" []]
97 , Syntax "int" [Syntax "3" []]
101 , Syntax "text" [Syntax "\"a\"" []]
102 , Syntax "text" [Syntax "\"b\"" []]
103 , Syntax "text" [Syntax "\"c\"" []]
108 ( (tyTuple2 :$ tyInt) :$ tyText
110 , "((\\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\"]))" )