example RExt

options
	dont_validate_unsafe = true
	require_consistency=false

typeside ty = literal {
	external_types
		Double -> "java.lang.Double" 
	external_parsers
		Double -> "x => new java.lang.Double(x)"
	external_functions
		plus : Double,Double -> Double = "(x, y) => x + y"
		neg : Double -> Double = "x => -x"
}

schema S = literal : ty {
	entities
		s s0
	foreign_keys
		ss : s0 -> s
	
}

schema T = literal : ty {
	entities
		t1 t2 t3
	foreign_keys
		f : t1 -> t3
		g : t2 -> t3
		l : t1 -> t1
		h : t2 -> t1
	path_equations
		t1 = t1.l
	

}

schema U = literal : ty {
	entities
		u11 u12 u21 u22 u3 u3x
	foreign_keys
		f1 : u11 -> u3
		f2 : u12 -> u3
		f1x: u11 -> u3x
		f2x: u12 -> u3x
		h  : u21 -> u11
		l  : u11 -> u11
		g1 : u21 -> u3
		g2 : u22 -> u3
		h2 : u21 -> u11
		h3 : u22 -> u12

	path_equations
		u11.l.l = u11.l

	

}

query qUT = literal : U -> T {
	entity
		t1 -> {from u11:u11 u12:u12
			   where u11.l.l.f1 = u12.f2   
			   foreign_keys f -> {u3 -> u11.f1  u3x -> u12.f2x}
			  	 l -> {u11 -> u11  u12 -> u12}
			   }

	entity
		t2 -> {from u21:u21 u22:u22
			   where u21.g1 = u22.g2  u21.h2.l.l.f1 = u22.h3.f2
			   foreign_keys g -> {u3 -> u21.g1  u3x -> u21.h.f1x}
							h -> {u11 -> u21.h2  u12 -> u22.h3}
			   }

	entity
		t3 -> {from u3:u3 u3x:u3x}



}

query qTS = literal : T -> S {
	entity
		s -> {from t1:t1 t2:t2
		      where t1.f = t2.g       
		attributes }
	entity
		s0 -> { from x:t2
		          where x.h.f = x.g     
	foreign_keys
		ss -> {t1 -> x.h t2 -> x }	}
}
query qUS = [qUT ; qTS]

########

query test1 = rext identity U identity U


instance I = literal : U {
	generators
		u11:u11 u12:u12 u21:u21 u22:u22 u3:u3 u3x:u3x
	equations
		
		u11.f1 = u3
		u12.f2 = u3
		u11.f1x = u3x
		u12.f2x = u3x
		u21.h = u11
		u11.l = u11
		u21.g1 = u3
		u22.g2 = u3
		u21.h2 = u11
		u22.h3 = u12
}

instance J = eval qTS (eval qUT I)
instance K = eval qUS I


########################

typeside Ty = literal {
	types
		Bool
	constants
		true false : Bool
	functions
		and : Bool, Bool -> Bool
	equations
		and(true, true) = true
		and(true, false)= false
		and(false,false)= false
		and(false,true) = false
}

schema SS = literal : Ty {
	entities
		E F
	foreign_keys
		f : E -> F
	attributes
		att : E -> Bool
}

instance II = literal : SS {
	generators
		e : E
	equations
		e.att=true
}

query QQ = literal : SS -> SS {
	entity
		E -> {from t:Bool x:E t2:Bool
		 where x.att=t
		attributes att -> and(x.att,t) foreign_keys f -> {y->x s->and(x.att,t2) t3->t2} }

	entity
		F -> {from s:Bool y:E t3:Bool}
}

instance JJ = eval QQ II

instance KK = coeval QQ II

#transform t = unit_query Q I   INFINTE

transform t2 = counit_query QQ II

transform t3 = coeval QQ (identity II)

query QQQQ = [QQ;QQ]

instance A = eval QQQQ II
instance B = eval QQ eval QQ II
instance A2 = coeval QQQQ II
instance B2 = coeval QQ coeval QQ II
Keywords:

schema_literal
eval
instance_literal
coeval
query_literal
transform_identity
counit_query
query_compose
typeside_literal
query_identity

Options:




instance II

E
IDattf
0true1
F
ID
1


instance KK

E
IDattf
0?01
F
ID
1


instance I

u3
ID
0
u3x
ID
1
u11
IDf1f1xl
2012
u12
IDf2f2x
301
u21
IDg1hh2
4022
u22
IDg2h3
503


instance JJ

E
IDattf
0(true and true)2
1(true and true)5
F
ID
2
3
4
5


instance A2

E
IDattf
0?01
F
ID
1


instance K

s
ID
0
s0
IDss
10


instance J

s
ID
0
s0
IDss
10


instance B2

E
IDattf
0?01
F
ID
1


instance A

E
IDattf
0((true and true) and (true and true))4
1((true and true) and (true and true))7
2((true and true) and (true and true))8
3((true and true) and (true and true))11
F
ID
4
5
6
7
8
9
10
11


instance B

E
IDattf
0((true and true) and (true and true))4
1((true and true) and (true and true))6
2((true and true) and (true and true))9
3((true and true) and (true and true))11
F
ID
4
5
6
7
8
9
10
11