polymorphism

GWT polymorphic lists with @ExtraTypes

北城余情 提交于 2020-01-01 19:40:09
问题 I have a little problem with a list that contains different types of elements and i would like to see if anyone of you have met the problem before. The issue should be solved with the use of @ExtraTypes, but it is not working for me, so i guess i am not using it correctly. So, the scenario is (bean names are changed for clarity): GENERAL: I am using GWT 2.5 with RequestFactory. SERVER-SIDE: I have a RootBean that contains, among other stuff, a List <ChildBean> . This ChildBean contains some

LINQ-to-XYZ polymorphism?

狂风中的少年 提交于 2020-01-01 14:45:15
问题 I have a situation where a client is requiring that we implement our data access code to use either an Oracle or SQL server database based on a runtime configuration settings. The production environment uses Oracle but both dev and QA are running against a SQL Server instance. (I don't have any control over this or have any background on why this is the case other than Oracle is their BI platform and dev wants to work with SQL Server.) Their request is to use LINQ-to-SQL / LINQ-to-Oracle for

polymorphism, generics and anonymous types C#

て烟熏妆下的殇ゞ 提交于 2020-01-01 10:39:08
问题 Consider the following scenario. Document -> Section -> Body -> Items Document has sections, a section contains a body. A body has some text and a list of items. The items is what the question is about. Sometimes the items is a basic list of string, but sometimes the items contain a list of a custom datatype. So: public class Document { public Section[] Sections{get;set;} } public class Section { public SectionType Type{get;set;} public Body {get;set;} } public class Body { //I want the items

How does the constraints package work?

随声附和 提交于 2020-01-01 08:18:12
问题 The idea behind Data.Constraint.Forall, as I understand it, is to use coercion in the implementation, but ensure safety using the type system. I have two questions regarding the latter. Why do we need two skolem variables — A and B? I would imagine that if a constraint is satisfied by an «unknown» type, then it is polymorphic. How does the second type give more safety? Why are these types called skolem variables? I thought that skolemnization is used to remove existential quantification, and

How does the constraints package work?

断了今生、忘了曾经 提交于 2020-01-01 08:18:08
问题 The idea behind Data.Constraint.Forall, as I understand it, is to use coercion in the implementation, but ensure safety using the type system. I have two questions regarding the latter. Why do we need two skolem variables — A and B? I would imagine that if a constraint is satisfied by an «unknown» type, then it is polymorphic. How does the second type give more safety? Why are these types called skolem variables? I thought that skolemnization is used to remove existential quantification, and

Django REST Serializer doing N+1 database calls for multiple nested relationship, 3 levels

廉价感情. 提交于 2020-01-01 06:11:22
问题 I have a situation where my model has a Foreign Key relationship: # models.py class Child(models.Model): parent = models.ForeignKey(Parent,) class Parent(models.Model): pass and my serializer: class ParentSerializer(serializer.ModelSerializer): child = serializers.SerializerMethodField('get_children_ordered') def get_children_ordered(self, parent): queryset = Child.objects.filter(parent=parent).select_related('parent') serialized_data = ChildSerializer(queryset, many=True, read_only=True,

What are uses of polymorphic kinds?

青春壹個敷衍的年華 提交于 2020-01-01 04:17:48
问题 Polymorphic kinds are an extension to Haskell's type system, supported by UHC, allowing data A x y = A (y x) to be typed (kinded?) as a -> (a -> *) -> * . What are they useful for? 回答1: One possible usage example can be using conal's TypeCompose for composing monad transformers in point-free style. type MyT = StateT Foo :. MaybeT :. ContT Bar (just as an example, I have no idea what one's going to do with those foos and bars..) Instead of: type MyT m = StateT Foo (MaybeT (ContT Bar m)) (this

Does anybody have any tips for managing polymorphic nested resources in Rails 3?

此生再无相见时 提交于 2020-01-01 03:10:52
问题 In config/routes.rb: resources :posts do resources :comments end resources :pictures do resources :comments end I would like to allow for more things to be commented on as well. I'm currently using mongoid (mongomapper isn't as compatible with Rails 3 yet as I would like), and comments are an embedded resource (mongoid can't yet handle polymorphic relational resources), which means that I do need the parent resource in order to find the comment. Are there any elegant ways to handle some of

Jackson custom deserializer for one field with polymorphic types

别说谁变了你拦得住时间么 提交于 2020-01-01 01:16:09
问题 Update: I tried to debug in jackson source code and find out that in the method deserialize(JsonParser jp, DeserializationContext ctxt) of SettableBeanProperty.java when the _valueTypeDeserializer isn't null, it will never use _valueDeserializer . Is this a correct assumption that TypeDeserializer should be more proper than ValueDeserializer? I'm trying to use @JsonDeserialize to define custom deserializer for one field with polymorphic types. I can succeed to use @JsonDeserialize and

A polymorphic collection of Curiously Recurring Template Pattern (CRTP) in C++?

╄→尐↘猪︶ㄣ 提交于 2020-01-01 00:52:07
问题 I've got a class Base from which I have two classes, DerivedA and DerivedB as defined below. template <typename Derived> class Base{ public: double interface(){ static_cast<Derived*>(this)->implementation(); } }; class DerivedA : public Base<DerivedA>{ public: double implementation(){ return 2.0;} }; class DerivedB : public Base<DerivedB>{ public: double implementation(){ return 1.0;} }; In short, I'm trying to do the following to maintain a collection of objects, some of which are DerivedA