Questions tagged [derived-types]

subtypes or composite types. commonly applies to sql or polymorphism/reflection in fortran or C#

167 questions
106
votes
3 answers

How does deriving work in Haskell?

Algebraic Data Types (ADTs) in Haskell can automatically become instances of some typeclasses (like Show, Eq) by deriving from them. data Maybe a = Nothing | Just a deriving (Eq, Ord) My question is, how does this deriving work, i.e. how does…
Abhinav Sarkar
  • 22,313
  • 10
  • 78
  • 95
17
votes
1 answer

SignalR 2.0 change Json Serializer to support derived type objects

Please note that I'm explicitly referencing SignalR 2.0 here ... I've seen some (nasty) approaches for this with SignalR 1.1/1.2 ... but none for 2.0 yet. Has anyone had any success with changing the SignalR 2.0 default json serializer to enable the…
typhoid
  • 305
  • 4
  • 13
11
votes
1 answer

invisible / hidden field in the constructor

I am ploughing through Learn You a Haskell for Great Good, and I have reached up to section 8.4, "Derived Instances". In this section, there's the following data type declaration: data Person = Person { firstName :: String ,…
Optimight
  • 2,809
  • 3
  • 25
  • 42
10
votes
2 answers

Derived type in PostgreSQL

Is it possible to create a "derived type" from a type? Like extends in Java. For instance I need these types: create type mytype as ( f1 int, --many other fields... fn varchar(10) ); create type mytype_extended as ( f1 int, …
bluish
  • 23,093
  • 23
  • 110
  • 171
8
votes
2 answers

Type-bound procedure gives error about non-polymorphic passed-object dummy argument

I'm trying to compile the Fortran module below (using gfortran 7.2.0). The point is to define a derived type that in turn contains two instances of the derived type bspline_3d from the bspline-fortran library…
Tor
  • 492
  • 4
  • 15
6
votes
1 answer

Holding a pointer to a C function inside a Fortran derived type

I have a Fortran DLL which is called from a C program, and one of my procedures needs periodically to call a callback function which is supplied by the C program. I currently have it working well in its 'simple' form, but I'd like to be able to…
Eos Pengwern
  • 1,215
  • 3
  • 16
  • 33
6
votes
4 answers

Named constants as components of a derived data type

It seems Fortran 90 does not allow named constants in derived data types. Is this true? The following code does not work. program my_prog implicit none type :: my_type integer, parameter :: a = 1 real(kind(1.d0)) :: b end type…
user1318806
  • 765
  • 2
  • 9
  • 12
6
votes
2 answers

Using 2d array vs array of derived type in Fortran 90

Assuming you want a list of arrays, each having the same size. Is it better performance-wise to use a 2D array : integer, allocatable :: data(:,:) or an array of derived types : type test integer, allocatable :: content(:) end type type(test),…
alex_reader
  • 669
  • 1
  • 5
  • 22
6
votes
2 answers

Can GDB be used to print values of allocatable arrays of a derived type in Fortran 90?

I have the following data structure in a Fortran90 program: TYPE derivedType CHARACTER(100) :: name = ' ' INTEGER :: type = 0 REAL(KIND(1.0D0)) :: property = 0.0 END TYPE derivedType TYPE (derivedType), ALLOCATABLE,…
Neal Kruis
  • 1,805
  • 2
  • 24
  • 45
5
votes
0 answers

Mapped types in Scala similar to Typescript Pick, Exclude, etc

Following on the heels of Mapped types in Scala Is there a way to mimic Pick, Exclude, Diff and etc. from Typescript in Scala? Using the a similar example as above: case class Person(name: String, age: Int, address: String, phone: String) is there…
Anton
  • 2,034
  • 20
  • 39
5
votes
2 answers

Constructor of derived types

I am trying to write a constructor for a derived type of an abstract one to solve this other question, but it seems that it's not working, or better, it isn't called at all. The aim is to have a runtime polymorphism setting the correct number of…
senseiwa
  • 2,081
  • 1
  • 19
  • 31
4
votes
0 answers

Using derived type member as a do loop iteration variable

EDIT: This has been marked as a duplicate of a question about using array elements to iterate a do loop. A similar question to be sure, but you can read the answers and not see anything about using non-array members of derived types. Even though…
bob.sacamento
  • 5,295
  • 7
  • 40
  • 95
4
votes
2 answers

Write statement cannot produce new lines within user-defined formatted I/O procedures for derived type

I want to implement the user-defined I/O procedures for the derived types in my Fortran code. However, write statements within those procedures cannot produce new lines between two sequential write statements. The derived type and procedures are…
Rubin
  • 323
  • 1
  • 9
4
votes
0 answers

Sending derived-type with allocatable array between MPI process

For the context, in my CFD simulation, my computational domain is divided in blocks. Each block has its own number of cells, each one containing various information. Blocks are distributed among processes through a domain decomposition algorithm to…
Coriolis
  • 408
  • 3
  • 10
4
votes
1 answer

Fortran array of derived types and memory leaks despite finalization

I defined a derived type and encountered some problems with memory deallocation although I had written the final procedure. The code is as follows module ModuleCoordinate implicit none type :: TCoordinate real(8),dimension(:),pointer ::…
Waltergu
  • 51
  • 4
1
2 3
11 12