ThoughtWorksInc / DeepDarkFantasy

A Programming Language for Deep Learning
Apache License 2.0
462 stars 47 forks source link

Do subtyping. #165

Closed MarisaKirisame closed 7 years ago

MarisaKirisame commented 7 years ago

Why: DBI (Term DBI) should entail DBI (Term Lang) so need some subtyping crtieria.

But Why Term? Dynamic Eval. If a Term need to be diff and evaled under different context, simply use Comp that return pair of different repr

How? Generic Solver returning constraint list, search through it by only climbing the class hierarchy, using a list to keep track of all alternative. Cannot solve instance of unknown <: C => unknown <: D, when C is subtype of D, though, but can always be resolved when in the concrete registeration. Also need registering and is a bit slow, a bit hard to write. Maybe manually saving instance with overlapping instance/incoherent instance would help.

Other solution: specialize into sub. Do not have such problem but create ton of similar Class. Also need to manually impl subtyping hierarchy registration for each new type. Could probably use Template Haskell to help ths.

MarisaKirisame commented 7 years ago

Just checked. We can manually cache by declaring exact overlapping instance. Toobad GHC cant memorized for us.

Zeroth solution seems to be saner.

MarisaKirisame commented 7 years ago

Cannot redo xor without Term. @dramforever I will hack it, stick to lang for now, and do subtyping later. Wanna give it a shot?

MarisaKirisame commented 7 years ago

I think I can fix it by generalizing over weight...

MarisaKirisame commented 7 years ago

fixed by 06d36cb073b48a11a48f2ac6d58c774596bdfa5e