{-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE PatternSynonyms #-} {-# LANGUAGE TypeFamilies #-} {-# OPTIONS_GHC -fno-warn-orphans #-} module Language.Symantic.Type.IO where import Data.Proxy import Data.Type.Equality ((:~:)(Refl)) import qualified System.IO as IO import Language.Symantic.Type.Root import Language.Symantic.Type.Type0 import Language.Symantic.Type.Type1 -- * Type 'Type_IO' -- | The list type. type Type_IO = Type_Type1 (Proxy IO) type Type_IO_Handle = Type_Type0 (Proxy IO.Handle) type Type_IO_FilePath = Type_Type0 (Proxy IO.FilePath) type Type_IO_Mode = Type_Type0 (Proxy IO.IOMode) pattern Type_IO :: root a -> Type_IO root (IO a) pattern Type_IO a = Type_Type1 Proxy a instance Constraint_Type1 Functor (Type_IO root) where constraint_type1 _c Type_Type1{} = Just Dict instance Constraint_Type1 Applicative (Type_IO root) where constraint_type1 _c Type_Type1{} = Just Dict instance Constraint_Type1 Monad (Type_IO root) where constraint_type1 _c Type_Type1{} = Just Dict instance -- Eq_Type Eq_Type root => Eq_Type (Type_IO 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_IO root) where eq_type1 Type_Type1{} Type_Type1{} = Just Refl instance -- String_from_Type String_from_Type root => String_from_Type (Type_IO root) where string_from_type (Type_Type1 _f a) = "[" ++ string_from_type a ++ "]" -- | Inject 'Type_IO' within a root type. type_io :: Lift_Type_Root Type_IO root => root h_a -> root (IO h_a) type_io = lift_type_root . Type_Type1 (Proxy::Proxy IO) -- | Inject 'Type_IO_Handle' within a root type. type_io_handle :: Lift_Type_Root Type_IO_Handle root => root IO.Handle type_io_handle = lift_type_root $ Type_Type0 (Proxy::Proxy IO.Handle) -- | Inject 'Type_IO_FilePath' within a root type. type_io_filepath :: Lift_Type_Root Type_IO_FilePath root => root IO.FilePath type_io_filepath = lift_type_root $ Type_Type0 (Proxy::Proxy IO.FilePath) -- | Inject 'Type_IO_Mode' within a root type. type_io_mode :: Lift_Type_Root Type_IO_Mode root => root IO.IOMode type_io_mode = lift_type_root $ Type_Type0 (Proxy::Proxy IO.IOMode)