]> Git — Sourcephile - haskell/symantic.git/blob - Language/Symantic/Type/Tuple.hs
init
[haskell/symantic.git] / Language / Symantic / Type / Tuple.hs
1 {-# LANGUAGE FlexibleContexts #-}
2 {-# LANGUAGE FlexibleInstances #-}
3 {-# LANGUAGE PatternSynonyms #-}
4 {-# LANGUAGE ScopedTypeVariables #-}
5 {-# LANGUAGE TypeFamilies #-}
6 {-# OPTIONS_GHC -fno-warn-orphans #-}
7 module Language.Symantic.Type.Tuple where
8
9 import Data.Proxy
10 import Language.Symantic.Type.Common
11
12 -- * Type 'Type_Tuple2'
13 -- | The (,) type.
14 type Type_Tuple2 = Type_Type2 (Proxy (,))
15
16 type instance Constraint2_of (Proxy (,))
17 = Constraint2_Empty
18
19 pattern Type_Tuple2
20 :: root a -> root b
21 -> Type_Tuple2 root ((,) a b)
22 pattern Type_Tuple2 a b
23 = Type_Type2 Proxy a b
24
25 instance -- String_from_Type
26 String_from_Type root =>
27 String_from_Type (Type_Tuple2 root) where
28 string_from_type (Type_Type2 _ a b) =
29 "(" ++ string_from_type a ++
30 ", " ++ string_from_type b ++ ")"
31
32 -- | Inject 'Type_Tuple2' within a root type.
33 type_tuple2
34 :: forall root h_a h_b.
35 Lift_Type_Root Type_Tuple2 root
36 => root h_a
37 -> root h_b
38 -> root (h_a, h_b)
39 type_tuple2 a b = lift_type_root
40 (Type_Tuple2 a b
41 ::Type_Tuple2 root (h_a, h_b))