{-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE PatternSynonyms #-} {-# LANGUAGE TypeFamilies #-} {-# OPTIONS_GHC -fno-warn-orphans #-} module Language.Symantic.Type.List where import Data.Proxy import Data.Type.Equality ((:~:)(Refl)) import Language.Symantic.Type.Common -- * Type 'Type_List' -- | The list type. type Type_List = Type_Type1 (Proxy []) pattern Type_List :: root a -> Type_List root ([] a) pattern Type_List a = Type_Type1 Proxy a instance -- Eq_Type Eq_Type root => Eq_Type (Type_Type1 (Proxy []) root) where eq_type (Type_Type1 _px1 a1) (Type_Type1 _px2 a2) | Just Refl <- a1 `eq_type` a2 = Just Refl eq_type _ _ = Nothing instance -- Eq_Type1 Eq_Type1 (Type_Type1 (Proxy []) root) where eq_type1 Type_Type1{} Type_Type1{} = Just Refl instance -- String_from_Type String_from_Type root => String_from_Type (Type_List root) where string_from_type (Type_Type1 _f a) = "[" ++ string_from_type a ++ "]" -- | Inject 'Type_List' within a root type. type_list :: Lift_Type_Root Type_List root => root h_a -> root ([] h_a) type_list = lift_type_root . Type_Type1 (Proxy::Proxy [])