F# not recognizing members of a record type - f#

I am doing a simple mapping and the compiler doesn't recognize the record's members.
The image shows the type OpeningHours itself is clearly ok, with all 3 properties showing:
But hovering over the marked property shows:
error FS0039: The field, constructor or member 'Day' is not defined.
Namespaces are all referenced and I even assign to the very same properties few lines below without any issue.

OpeningHours is a class, not a record. This is one way to create an instance of the class:
OpeningHours(day = oh.Day, opens = oh.Opens, closes = oh.Closes)

Based on the constructor and properties, it looks like OpeningHours is defined as a class, not a record. The record syntax can't be used with classes, so the solution is either to change OpeningHours to a record, or to instantiate it using its existing constructor.

Related

Core Data: How to access/set inherited attributed?

I have an Employee entity which inherits from a Human entity. I cannot access or set the inherited attribute (property) name on my Employee instance in code using dot syntax, however using setValue(forKey) works.
I have included 2 screen shots:
The Human entity is abstract, however even if I don't put abstract it still does not let me access the inherited attributes via dot syntax. I also tried changing the Codegen to Class Definition and still doesn't work. Am I doing something wrong or is this the standard way of accessing inherited attributes. Any solution to this problem is helpful.

Get type of variable at run-time without having it assigned to an instance of an object and without mirrors

Is it possible to get the type of a variable in Dart at run-time, without having it assigned to an instance of an object and without using mirrors?
I know I can do this without mirrors (which is great!):
Foo foo;
foo = new Foo();
var fooType = foo.runTimeType; // This will give me a type of "Foo"
But I want to know the type of the variable before it is assigned to an object:
Foo foo;
var fooType = foo.runTimeType; // This will not give me a type of "Foo"
I am guessing it is not possible since the typing info is lost in run-time but would like to have it confirmed.
(My actual scenario is that I am doing dependency injection into a Polymer Element using Custom Events. I would like to put as much of this code as possible in an element base-class and have as little code as possible in each derived element class. One thing that I need to do this is to know the type of variables that are to be injected).

Data type converter not working with embedded object in Struts 2

I'm creating a data type converter within Struts 2 framework and got the problem below:
in the action conversion property file, I need to specify a property like this:
foo.field1.field2 = coverterClassName
field1 is embedded object within foo, which has field2 as one of the fields.
I have tried everything and couldn't make this working unless I put the property file
into same package as class Foo, which hooks up the struts2 with model class.
Has anyone had this problem before and is there any other solution for it?
Because you are doing a class wide conversion, your conversion property file should be
in the same location of the classpath as the target bean.
if your target bean is an action bean, then it should be in the same package as the action class. More about it Applying a Type Converter to a bean or model.
You might also see this answer for how to apply application wide conversion to your field type. Note, you can do the same type conversion using annotations.

Type inheritance

In a class unit I have the type
type
TFolderType = (
dirRoot,
dirDatabase,
dirDocs,
dirConfig,
dirBackup,
dirDown,
dirUp,
dirScripts,
dirLicense,
dirImages,
dirMail,
dirProjects,
dirInput,
dirOutput
);
Now I would like to inherit this class from another class and add some extra elements
Is that in any way possible or can I do this in another way
I have thought of creating a class with all the elements as properties but I am not sure if that is the way to go
Like David says, it is not a class.
As an alternative, you can declare your bigger enumeration like:
type
TThingType = (dirThingA, dirRoot, dirDataBase, ..., dirOutput, dirThingY, dirThingZ);
And then declare your TFolderType as:
type
TFolderType = dirRoot..dirOutput;
Some concerns:
A folder 'needs' to be of type thing
The prefix dir 'needs' to be meaningful for both thing and folder
Current code that assumes enumeration index of the TFolderType elements needs to be rewritten, or add all 'new' elements in the back.
That is not class, rather it is an enumerated type. You cannot use inheritance with enumerated types. You will need to create a new enumerated type. Or perhaps solve the problem using something other than an enumerated type.

difference between wrapper class and primitive type definition

I am working on Struts 2 and using Eclipselink JPA.
In my entity classes, I have defined a variable of primitive type, i.e private int ductRun; and other one of wrapper class type i.e private Integer ductQty.
On the JSP page, if user submit the form leaving both the fields blank, the primitive type variables(ductRun) gets initialize automatically to "0", and wrapper type variable (ductQty) remain null. And the validation required of struts for field ductRun is not working.
Now I want to know the reason behind it, where is initializing the ductRun and whether it is a good approach to define all the variables in entity class of primitive type.
Hope it is understandable.

Resources