1 {-# LANGUAGE DefaultSignatures #-}
2 {-# LANGUAGE FlexibleContexts #-}
3 {-# LANGUAGE FlexibleInstances #-}
4 {-# LANGUAGE MultiParamTypeClasses #-}
5 {-# LANGUAGE PolyKinds #-}
6 {-# LANGUAGE ScopedTypeVariables #-}
7 {-# LANGUAGE TypeFamilies #-}
8 {-# LANGUAGE TypeOperators #-}
9 {-# LANGUAGE NoMonomorphismRestriction #-}
10 {-# OPTIONS_GHC -fno-warn-orphans #-}
11 -- | Expression for 'Eq'.
12 module Language.Symantic.Expr.Eq where
14 import Data.Proxy (Proxy(..))
15 import Data.Type.Equality ((:~:)(Refl))
16 import Prelude hiding ((==))
18 import Language.Symantic.Trans.Common
19 import Language.Symantic.Type
20 import Language.Symantic.Expr.Root
21 import Language.Symantic.Expr.Error
22 import Language.Symantic.Expr.From
26 class Sym_Eq repr where
27 (==) :: Eq a => repr a -> repr a -> repr Bool
28 default (==) :: (Trans t repr, Eq a)
29 => t repr a -> t repr a -> t repr Bool
30 (==) = trans_map2 (==)
35 data Expr_Eq (root:: *)
36 type instance Root_of_Expr (Expr_Eq root) = root
37 type instance Type_of_Expr (Expr_Eq root) = No_Type
38 type instance Sym_of_Expr (Expr_Eq root) repr = (Sym_Eq repr)
39 type instance Error_of_Expr ast (Expr_Eq root) = No_Error_Expr
41 instance Constraint_Type Eq (Type_Var0 root)
42 instance Constraint_Type Eq (Type_Var1 root)
45 :: forall root ty ast hs ret.
46 ( ty ~ Type_Root_of_Expr (Expr_Eq root)
47 , Lift_Type Type_Bool (Type_of_Expr root)
50 , Lift_Error_Expr (Error_Expr (Error_of_Type ast ty) ty ast)
51 (Error_of_Expr ast root)
52 , Root_of_Expr root ~ root
53 , Constraint_Type Eq ty
55 -> Expr_From ast (Expr_Eq root) hs ret
56 eq_from ast_x ast_y ex ast ctx k =
57 expr_from (Proxy::Proxy root) ast_x ctx $
58 \(ty_x::ty h_x) (Forall_Repr_with_Context x) ->
59 expr_from (Proxy::Proxy root) ast_y ctx $
60 \(ty_y::ty h_y) (Forall_Repr_with_Context y) ->
61 check_eq_type ex ast ty_x ty_y $ \Refl ->
62 check_constraint_type ex (Proxy::Proxy Eq) ast ty_x $ \Dict ->
63 k type_bool $ Forall_Repr_with_Context $