From 249e811c7769b773f9a50c3eb311c2811524d0fe Mon Sep 17 00:00:00 2001 From: Michael Sippel Date: Mon, 21 Aug 2023 15:49:07 +0200 Subject: [PATCH] move TypeTerm editor to editors module; remove make_editor.rs and distribute context initialization into editor submodules --- nested/src/editors/char/mod.rs | 10 +- nested/src/editors/integer/ctx.rs | 8 +- nested/src/editors/integer/mod.rs | 2 +- nested/src/editors/list/ctx.rs | 45 ++++++ nested/src/editors/list/editor.rs | 33 ---- nested/src/editors/list/mod.rs | 4 +- nested/src/editors/list/pty_editor.rs | 13 +- nested/src/editors/mod.rs | 8 +- nested/src/editors/typeterm/ctx.rs | 117 ++++++++++++++ .../editor.rs => editors/typeterm/mod.rs} | 104 +----------- nested/src/type_system/context.rs | 20 +++ nested/src/type_system/make_editor.rs | 152 ------------------ nested/src/type_system/mod.rs | 5 +- 13 files changed, 215 insertions(+), 306 deletions(-) create mode 100644 nested/src/editors/list/ctx.rs create mode 100644 nested/src/editors/typeterm/ctx.rs rename nested/src/{type_system/editor.rs => editors/typeterm/mod.rs} (76%) delete mode 100644 nested/src/type_system/make_editor.rs diff --git a/nested/src/editors/char/mod.rs b/nested/src/editors/char/mod.rs index 708424e..4ea87ff 100644 --- a/nested/src/editors/char/mod.rs +++ b/nested/src/editors/char/mod.rs @@ -7,7 +7,7 @@ use { buffer::singleton::* }, crate::{ - type_system::{Context, ReprTree}, + type_system::{Context, ReprTree, TypeTerm}, terminal::{TerminalAtom, TerminalStyle}, tree::{NestedNode, TreeNavResult}, commander::{ObjCommander} @@ -16,6 +16,14 @@ use { std::sync::RwLock }; +pub fn init_ctx( ctx: &mut Context ) { + ctx.add_node_ctor( + "Char", + Arc::new(|ctx: Arc>, _ty: TypeTerm, _depth: usize| { + Some(CharEditor::new_node(ctx)) + })); +} + pub struct CharEditor { ctx: Arc>, data: SingletonBuffer diff --git a/nested/src/editors/integer/ctx.rs b/nested/src/editors/integer/ctx.rs index f7f07c3..e197613 100644 --- a/nested/src/editors/integer/ctx.rs +++ b/nested/src/editors/integer/ctx.rs @@ -15,10 +15,7 @@ use { cgmath::Point2 }; -pub fn init_integer_ctx(parent: Arc>) -> Arc> { - let ctx0 = Arc::new(RwLock::new(Context::with_parent(Some(parent)))); - - let mut ctx = ctx0.write().unwrap(); +pub fn init_ctx(ctx: &mut Context) { ctx.add_typename("MachineInt".into()); ctx.add_typename("u32".into()); ctx.add_typename("u64".into()); @@ -141,8 +138,5 @@ pub fn init_integer_ctx(parent: Arc>) -> Arc> { ctx.add_typename("Duration".into()); ctx.add_typename("Seconds".into()); ctx.add_typename("ℕ".into()); - - drop(ctx); - ctx0 } diff --git a/nested/src/editors/integer/mod.rs b/nested/src/editors/integer/mod.rs index d8309f8..bdbf565 100644 --- a/nested/src/editors/integer/mod.rs +++ b/nested/src/editors/integer/mod.rs @@ -7,6 +7,6 @@ pub use { add::Add, editor::{DigitEditor, PosIntEditor}, radix::RadixProjection, - ctx::init_integer_ctx + ctx::init_ctx }; diff --git a/nested/src/editors/list/ctx.rs b/nested/src/editors/list/ctx.rs new file mode 100644 index 0000000..69fe434 --- /dev/null +++ b/nested/src/editors/list/ctx.rs @@ -0,0 +1,45 @@ +use { + r3vi::{ + view::{port::UpdateTask, OuterViewPort, singleton::*, sequence::*}, + buffer::{singleton::*, vec::*} + }, + crate::{ + type_system::{Context, TypeTerm, ReprTree}, + editors::list::{ListEditor, ListCursor, ListCursorMode, ListCmd, PTYListController, PTYListStyle}, + tree::{NestedNode, TreeNav, TreeCursor}, + diagnostics::Diagnostics + }, + std::sync::{Arc, RwLock} +}; + +//<<<<>>>><<>><><<>><<<*>>><<>><><<>><<<<>>>> + +pub fn init_ctx(ctx: &mut Context) { + ctx.add_list_typename("ListCmd".into()); + ctx.add_list_typename("List".into()); + + ctx.add_node_ctor( + "List", Arc::new( + |ctx: Arc>, ty: TypeTerm, depth: usize| { + match ty { + TypeTerm::App(args) => { + if args.len() > 1 { + let typ = args[1].clone(); + + let mut node = ListEditor::new(ctx.clone(), typ).into_node(depth); + + PTYListController::for_node( &mut node, Some(','), Some('}') ); + PTYListStyle::for_node( &mut node, ("{",", ","}") ); + + Some(node) + } else { + None + } + } + _ => None + } + } + ) + ); +} + diff --git a/nested/src/editors/list/editor.rs b/nested/src/editors/list/editor.rs index 1714415..180f17b 100644 --- a/nested/src/editors/list/editor.rs +++ b/nested/src/editors/list/editor.rs @@ -28,37 +28,6 @@ pub struct ListEditor { } impl ListEditor { - pub fn init_ctx(ctx: &Arc>) { - let mut ctx = ctx.write().unwrap(); - - ctx.add_list_typename("ListCmd".into()); - - ctx.add_list_typename("List".into()); - ctx.add_node_ctor( - "List", Arc::new( - |ctx: Arc>, ty: TypeTerm, depth: usize| { - match ty { - TypeTerm::App(args) => { - if args.len() > 1 { - let typ = args[1].clone(); - - let mut node = ListEditor::new(ctx.clone(), typ).into_node(depth); - - PTYListController::for_node( &mut node, Some(','), Some('}') ); - PTYListStyle::for_node( &mut node, ("{",", ","}") ); - - Some(node) - } else { - None - } - } - _ => None - } - } - ) - ); - } - pub fn new( ctx: Arc>, typ: TypeTerm, @@ -353,7 +322,6 @@ impl ListEditor { let depth = item.depth; if let Some(head_editor) = item.editor.get() { - eprintln!("listlistsplit:editor = {:?}", Arc::into_raw(head_editor.clone())); let head = head_editor.downcast::>().unwrap(); @@ -419,7 +387,6 @@ impl ListEditor { idx: Some(idx - 1), mode: ListCursorMode::Select } ); - } } } diff --git a/nested/src/editors/list/mod.rs b/nested/src/editors/list/mod.rs index f67e533..c929369 100644 --- a/nested/src/editors/list/mod.rs +++ b/nested/src/editors/list/mod.rs @@ -6,12 +6,14 @@ pub mod nav; pub mod segment; pub mod pty_editor; pub mod cmd; +pub mod ctx; pub use { cursor::{ListCursor, ListCursorMode}, editor::ListEditor, segment::{ListSegment, ListSegmentSequence}, pty_editor::{PTYListStyle, PTYListController}, - cmd::ListCmd + cmd::ListCmd, + ctx::init_ctx }; diff --git a/nested/src/editors/list/pty_editor.rs b/nested/src/editors/list/pty_editor.rs index 1d40f37..df5a4f5 100644 --- a/nested/src/editors/list/pty_editor.rs +++ b/nested/src/editors/list/pty_editor.rs @@ -176,24 +176,28 @@ impl PTYListController { match cur.mode { ListCursorMode::Insert => { + eprintln!("PTYList(insert): create new child and forward cmd"); let mut new_edit = Context::make_node(&e.ctx, e.typ.clone(), self.depth).unwrap(); new_edit.goto(TreeCursor::home()); match new_edit.send_cmd_obj(cmd_obj.clone()) { TreeNavResult::Continue => { + eprintln!("PTYList(insert): child returned cont"); e.insert(Arc::new(RwLock::new(new_edit))); TreeNavResult::Continue } - TreeNavResult::Exit => TreeNavResult::Exit + TreeNavResult::Exit => { + eprintln!("PTYList(insert): child returned exit"); + TreeNavResult::Exit + } } }, ListCursorMode::Select => { if let Some(mut item) = e.get_item_mut() { - - eprintln!("PTYList: forward any cmd to current child item"); + eprintln!("PTYList(select): forward any cmd to current child item"); let res = item.write().unwrap().send_cmd_obj(cmd_obj.clone()); let child_close_char = item.read().unwrap().close_char.get(); - eprintln!("PTYList: returned"); + eprintln!("PTYList(select): child returned"); match res { TreeNavResult::Continue => TreeNavResult::Continue, @@ -224,7 +228,6 @@ impl PTYListController { } } - use r3vi::view::singleton::SingletonView; use crate::commander::ObjCommander; diff --git a/nested/src/editors/mod.rs b/nested/src/editors/mod.rs index b126643..a93800c 100644 --- a/nested/src/editors/mod.rs +++ b/nested/src/editors/mod.rs @@ -1,7 +1,9 @@ -pub mod char; -pub mod integer; - pub mod list; pub mod product; pub mod sum; + +pub mod char; +pub mod integer; +pub mod typeterm; + diff --git a/nested/src/editors/typeterm/ctx.rs b/nested/src/editors/typeterm/ctx.rs new file mode 100644 index 0000000..9ce71eb --- /dev/null +++ b/nested/src/editors/typeterm/ctx.rs @@ -0,0 +1,117 @@ +use { + r3vi::{ + buffer::singleton::*, + view::{singleton::*, sequence::*, OuterViewPort}, + projection::flatten_grid::*, + projection::flatten_singleton::* + }, + crate::{ + type_system::{Context, TypeID, TypeTerm, ReprTree, MorphismTypePattern}, + terminal::{TerminalEvent, TerminalStyle}, + editors::{sum::*, list::{ListCursorMode, ListEditor, PTYListStyle, PTYListController}, typeterm::{State, TypeTermEditor}}, + tree::{NestedNode, TreeNav, TreeNavResult, TreeCursor}, + commander::ObjCommander, + PtySegment + }, + termion::event::{Key}, + std::{sync::{Arc, RwLock}, any::Any}, + cgmath::{Vector2, Point2} +}; + +pub fn init_ctx(ctx: &mut Context) { + ctx.add_list_typename("Type".into()); // = Lit | Sym | App | Ladder + ctx.add_list_typename("Type::Lit".into()); // = Num | char + ctx.add_list_typename("Type::Lit::Num".into()); // [0-9]* + ctx.add_list_typename("Type::Lit::Char".into()); // . + ctx.add_list_typename("Type::Sym".into()); // = Fun | Var + ctx.add_list_typename("Type::Sym::Fun".into()); // [a-zA-Z][a-zA-Z0-9]* + ctx.add_list_typename("Type::Sym::Var".into()); // [a-zA-Z][a-zA-Z0-9]* + ctx.add_list_typename("Type::App".into()); // = + ctx.add_list_typename("Type::Ladder".into()); // = T1~T2~... + + ctx.add_morphism( + MorphismTypePattern { src_tyid: ctx.get_typeid("List"), dst_tyid: ctx.get_typeid("Type").unwrap() }, + Arc::new(move |mut node, _dst_type:_| { + let mut new_node = TypeTermEditor::with_node( node.ctx.clone(), node.depth.get(), node.clone(), State::Any ); + Some(new_node) + })); + + ctx.add_morphism( + MorphismTypePattern { src_tyid: ctx.get_typeid("List"), dst_tyid: ctx.get_typeid("Type::Ladder").unwrap() }, + Arc::new(|mut node, _dst_type: _| { + PTYListController::for_node( &mut node, Some('~'), None ); + PTYListStyle::for_node( &mut node, ("","~","") ); + Some(node) + })); + + ctx.add_morphism( + MorphismTypePattern { src_tyid: ctx.get_typeid("List"), dst_tyid: ctx.get_typeid("Type::App").unwrap() }, + Arc::new( |mut node, _dst_type: _| { + PTYListController::for_node( &mut node, Some(' '), Some('>') ); + PTYListStyle::for_node( &mut node, ("<"," ",">") ); + Some(node) + })); + + ctx.add_morphism( + MorphismTypePattern { src_tyid: ctx.get_typeid("List"), dst_tyid: ctx.get_typeid("Type::Sym").unwrap() }, + Arc::new(|mut node, _dst_type:_| { + PTYListController::for_node( &mut node, Some(' '), None ); + PTYListStyle::for_node( &mut node, ("","","") ); + Some(node) + })); + + ctx.add_morphism( + MorphismTypePattern { src_tyid: ctx.get_typeid("List"), dst_tyid: ctx.get_typeid("Type::Sym::Fun").unwrap() }, + Arc::new(|mut node, _dst_type:_| { + PTYListController::for_node( &mut node, Some(' '), None ); + PTYListStyle::for_node( &mut node, ("","","") ); + Some(node) + })); + + ctx.add_morphism( + MorphismTypePattern { src_tyid: ctx.get_typeid("List"), dst_tyid: ctx.get_typeid("Type::Sym::Var").unwrap() }, + Arc::new(|mut node, _dst_type:_| { + PTYListController::for_node( &mut node, Some(' '), None ); + PTYListStyle::for_node( &mut node, ("","","") ); + + // display variables blue color + if let Some(v) = node.view { + node.view = Some( + v.map_item(|i,p| p.add_style_front(TerminalStyle::fg_color((5, 120, 240))))); + } + Some(node) + })); + + ctx.add_morphism( + MorphismTypePattern { src_tyid: ctx.get_typeid("PosInt"), dst_tyid: ctx.get_typeid("Type::Lit::Num").unwrap() }, + Arc::new(|mut node, _dst_type:_| { + Some(node) + })); + + ctx.add_morphism( + MorphismTypePattern { src_tyid: ctx.get_typeid("List"), dst_tyid: ctx.get_typeid("Type::Lit::Char").unwrap() }, + Arc::new(|mut node, _dst_type:_| { + let mut grid = r3vi::buffer::index_hashmap::IndexBuffer::new(); + + grid.insert_iter( + vec![ + (Point2::new(0,0), crate::terminal::make_label("'")), + (Point2::new(1,0), node.view.clone().unwrap()), + (Point2::new(2,0), crate::terminal::make_label("'")), + ] + ); + + node.close_char.set(Some('\'')); + node.view = Some( + grid.get_port() + .flatten() + ); + + Some(node) + })); + + ctx.add_node_ctor("Type", Arc::new( + |ctx: Arc>, _ty: TypeTerm, depth: usize| { + Some(TypeTermEditor::new_node(ctx, depth)) + })); +} diff --git a/nested/src/type_system/editor.rs b/nested/src/editors/typeterm/mod.rs similarity index 76% rename from nested/src/type_system/editor.rs rename to nested/src/editors/typeterm/mod.rs index a25d458..7c320af 100644 --- a/nested/src/type_system/editor.rs +++ b/nested/src/editors/typeterm/mod.rs @@ -1,3 +1,7 @@ +mod ctx; + +pub use ctx::init_ctx; + use { r3vi::{ buffer::singleton::*, @@ -19,7 +23,7 @@ use { }; #[derive(PartialEq, Eq, Clone, Copy)] -enum State { +pub enum State { Any, Num, Char, @@ -45,104 +49,6 @@ pub struct TypeTermEditor { } impl TypeTermEditor { - pub fn init_ctx(ctx: &mut Context) { - ctx.add_list_typename("Type".into()); // = Lit | Sym | App | Ladder - ctx.add_list_typename("Type::Lit".into()); // = Num | char - ctx.add_list_typename("Type::Lit::Num".into()); // [0-9]* - ctx.add_list_typename("Type::Lit::Char".into()); // . - ctx.add_list_typename("Type::Sym".into()); // = Fun | Var - ctx.add_list_typename("Type::Sym::Fun".into()); // [a-zA-Z][a-zA-Z0-9]* - ctx.add_list_typename("Type::Sym::Var".into()); // [a-zA-Z][a-zA-Z0-9]* - ctx.add_list_typename("Type::App".into()); // = - ctx.add_list_typename("Type::Ladder".into()); // = T1~T2~... - - ctx.add_morphism( - MorphismTypePattern { src_tyid: ctx.get_typeid("List"), dst_tyid: ctx.get_typeid("Type").unwrap() }, - Arc::new(move |mut node, _dst_type:_| { - let mut new_node = TypeTermEditor::with_node( node.ctx.clone(), node.depth.get(), node.clone(), State::Any ); - Some(new_node) - })); - - ctx.add_morphism( - MorphismTypePattern { src_tyid: ctx.get_typeid("List"), dst_tyid: ctx.get_typeid("Type::Ladder").unwrap() }, - Arc::new(|mut node, _dst_type: _| { - PTYListController::for_node( &mut node, Some('~'), None ); - PTYListStyle::for_node( &mut node, ("","~","") ); - Some(node) - })); - - ctx.add_morphism( - MorphismTypePattern { src_tyid: ctx.get_typeid("List"), dst_tyid: ctx.get_typeid("Type::App").unwrap() }, - Arc::new( |mut node, _dst_type: _| { - PTYListController::for_node( &mut node, Some(' '), Some('>') ); - PTYListStyle::for_node( &mut node, ("<"," ",">") ); - Some(node) - })); - - ctx.add_morphism( - MorphismTypePattern { src_tyid: ctx.get_typeid("List"), dst_tyid: ctx.get_typeid("Type::Sym").unwrap() }, - Arc::new(|mut node, _dst_type:_| { - PTYListController::for_node( &mut node, Some(' '), None ); - PTYListStyle::for_node( &mut node, ("","","") ); - Some(node) - })); - - ctx.add_morphism( - MorphismTypePattern { src_tyid: ctx.get_typeid("List"), dst_tyid: ctx.get_typeid("Type::Sym::Fun").unwrap() }, - Arc::new(|mut node, _dst_type:_| { - PTYListController::for_node( &mut node, Some(' '), None ); - PTYListStyle::for_node( &mut node, ("","","") ); - Some(node) - })); - - ctx.add_morphism( - MorphismTypePattern { src_tyid: ctx.get_typeid("List"), dst_tyid: ctx.get_typeid("Type::Sym::Var").unwrap() }, - Arc::new(|mut node, _dst_type:_| { - PTYListController::for_node( &mut node, Some(' '), None ); - PTYListStyle::for_node( &mut node, ("","","") ); - - // display variables blue color - if let Some(v) = node.view { - node.view = Some( - v.map_item(|i,p| p.add_style_front(TerminalStyle::fg_color((5, 120, 240))))); - } - Some(node) - })); - - ctx.add_morphism( - MorphismTypePattern { src_tyid: ctx.get_typeid("PosInt"), dst_tyid: ctx.get_typeid("Type::Lit::Num").unwrap() }, - Arc::new(|mut node, _dst_type:_| { - Some(node) - })); - - ctx.add_morphism( - MorphismTypePattern { src_tyid: ctx.get_typeid("List"), dst_tyid: ctx.get_typeid("Type::Lit::Char").unwrap() }, - Arc::new(|mut node, _dst_type:_| { - let mut grid = r3vi::buffer::index_hashmap::IndexBuffer::new(); - - grid.insert_iter( - vec![ - (Point2::new(0,0), crate::terminal::make_label("'")), - (Point2::new(1,0), node.view.clone().unwrap()), - (Point2::new(2,0), crate::terminal::make_label("'")), - ] - ); - - node.close_char.set(Some('\'')); - node.view = Some( - grid.get_port() - .flatten() - ); - - Some(node) - })); - - ctx.add_node_ctor("Type", Arc::new( - |ctx: Arc>, _ty: TypeTerm, depth: usize| { - Some(TypeTermEditor::new_node(ctx, depth)) - })); - } - pub fn from_type_term(ctx: Arc>, depth: usize, term: &TypeTerm) -> NestedNode { let mut node = TypeTermEditor::new_node(ctx.clone(), depth); node.goto(TreeCursor::home()); diff --git a/nested/src/type_system/context.rs b/nested/src/type_system/context.rs index 190a794..3bda270 100644 --- a/nested/src/type_system/context.rs +++ b/nested/src/type_system/context.rs @@ -115,6 +115,25 @@ pub struct Context { parent: Option>>, } +impl Default for Context { + fn default() -> Context { + let mut ctx = Context::new(); + + ctx.add_list_typename("Seq".into()); + ctx.add_list_typename("Sequence".into()); + ctx.add_list_typename("SepSeq".into()); + ctx.add_typename("NestedNode".into()); + ctx.add_typename("TerminalEvent".into()); + + crate::editors::list::init_ctx( &mut ctx ); + crate::editors::char::init_ctx( &mut ctx ); + crate::editors::integer::init_ctx( &mut ctx ); + crate::editors::typeterm::init_ctx( &mut ctx ); + + ctx + } +} + impl Into for (&Arc>, &str) { fn into(self) -> TypeTerm { self.0.read().unwrap().type_term_from_str(self.1).expect("could not parse type term") @@ -396,3 +415,4 @@ impl Context { } //<<<<>>>><<>><><<>><<<*>>><<>><><<>><<<<>>>> + diff --git a/nested/src/type_system/make_editor.rs b/nested/src/type_system/make_editor.rs deleted file mode 100644 index 7c32483..0000000 --- a/nested/src/type_system/make_editor.rs +++ /dev/null @@ -1,152 +0,0 @@ -use { - crate::{ - type_system::{Context, TypeTerm, ReprTree}, - editors::{ - char::*, - list::*, - integer::*, - product::* - }, - tree::{NestedNode}, - diagnostics::{Diagnostics}, - type_system::{MorphismTypePattern}, - }, - std::sync::{Arc, RwLock}, - cgmath::Point2 -}; - -pub fn init_mem_ctx(parent: Arc>) -> Arc> { - let ctx = Arc::new(RwLock::new(Context::with_parent(Some(parent)))); - - ctx.write().unwrap().add_node_ctor( - "Vec", Arc::new( - |ctx: Arc>, ty: TypeTerm, depth: usize| { - match ty { - TypeTerm::App(args) => { - if args.len() > 1 { - let buf = r3vi::buffer::vec::VecBuffer::::new(); - let data = ReprTree::new_leaf( - ctx.read().unwrap().type_term_from_str("( Char )").unwrap(), - buf.get_port().into() - ); - - Some( - NestedNode::new(ctx, data, depth) - .set_editor(Arc::new(RwLock::new(buf))) - ) - } else { - None - } - } - _ => None - } - } - ) - ); - - ctx -} - -pub fn init_editor_ctx(parent: Arc>) -> Arc> { - let ctx0 = Arc::new(RwLock::new(Context::with_parent(Some(parent)))); - - ListEditor::init_ctx( &ctx0 ); - - let mut ctx = ctx0.write().unwrap(); - // TODO:: CharEditor::init_ctx( &ctx ); - - ctx.add_node_ctor( - "Char", Arc::new( - |ctx: Arc>, _ty: TypeTerm, _depth: usize| { - Some(CharEditor::new_node(ctx)) - } - ) - ); - - ctx.add_list_typename("Seq".into()); - ctx.add_list_typename("Sequence".into()); - ctx.add_list_typename("SepSeq".into()); - ctx.add_typename("NestedNode".into()); - - ctx.add_list_typename("Symbol".into()); - let pattern = MorphismTypePattern { - src_tyid: ctx.get_typeid("List"), - dst_tyid: ctx.get_typeid("Symbol").unwrap() - }; - ctx.add_morphism(pattern, - Arc::new( - |mut node, _dst_type:_| { - PTYListController::for_node( &mut node, None, None ); - PTYListStyle::for_node( &mut node, ("","","") ); - - Some(node) - } - ) - ); - - ctx.add_node_ctor( - "Symbol", Arc::new( - |ctx: Arc>, dst_typ: TypeTerm, depth: usize| { - let mut node = Context::make_node( - &ctx, - (&ctx, "( List Char )").into(), - depth+1 - ).expect("nested node"); - - node = node.morph(dst_typ); - - Some(node) - } - ) - ); - - ctx.add_list_typename("String".into()); - let pattern = MorphismTypePattern { - src_tyid: ctx.get_typeid("List"), - dst_tyid: ctx.get_typeid("String").unwrap() - }; - ctx.add_morphism(pattern, - Arc::new( - |mut node, _dst_type:_| { - PTYListController::for_node( &mut node, None, Some('\"') ); - PTYListStyle::for_node( &mut node, ("\"","","\"") ); - Some(node) - } - ) - ); - - ctx.add_node_ctor( - "String", Arc::new( - |ctx: Arc>, dst_typ: TypeTerm, depth: usize| { - let mut node = Context::make_node( - &ctx, - TypeTerm::App(vec![ - TypeTerm::TypeID(ctx.read().unwrap().get_typeid("List").unwrap()), - TypeTerm::new(ctx.read().unwrap().get_typeid("Char").unwrap()) - ]), - depth+1 - ).unwrap(); - - node = node.morph(dst_typ); - - Some(node) - } - ) - ); -/* - ctx.add_list_typename("TypeTerm".into()); - ctx.add_node_ctor( - "TypeTerm", Arc::new( - |ctx: Arc>, _ty: TypeTerm, depth: usize| { - Some(TypeTermEditor::new(ctx, depth).into_node(depth)) - } - ) - ); -*/ - ctx.add_typename("TerminalEvent".into()); - - drop(ctx); - ctx0 -} - - diff --git a/nested/src/type_system/mod.rs b/nested/src/type_system/mod.rs index 2bfde44..f52f6ef 100644 --- a/nested/src/type_system/mod.rs +++ b/nested/src/type_system/mod.rs @@ -4,15 +4,12 @@ pub mod dict; pub mod term; //pub mod ladder; pub mod repr_tree; -pub mod make_editor; -pub mod editor; pub use { dict::*, // ladder::*, repr_tree::*, term::*, - context::{Context, MorphismMode, MorphismType, MorphismTypePattern}, - make_editor::* + context::{Context, MorphismMode, MorphismType, MorphismTypePattern} };