Questions tagged [types]
Types, and type systems, are used to enforce levels of abstraction in programs.
types
4,724
questions with no upvoted or accepted answers
16
votes
0
answers
420
views
Is a function that curries the first argument of a list of functions typeable in Typed Racket?
I can write a simple function in untyped Racket called curry-all that takes a list of functions, all of which accept the same kind of value for their first argument, and produces a list of functions ...
11
votes
0
answers
490
views
In Idris, why do interface parameters have to be type or data constructors?
To get some practice with Idris, I've been trying to represent various basic algebraic structures as interfaces. The way I thought of organizing things at first was to make the parameters of a given ...
10
votes
0
answers
979
views
C# Pick Utility Type
In Typescript, there is a Pick Utility Type. Is it possible to do the same in C#? For example:
public class SomeClassA {
public string SomePropA { get; set; }
public string SomePropB { get; ...
10
votes
1
answer
401
views
Why nested types' scope does not include derived classes?
I wonder why the scope of nested types does not include derived classes in Delphi; it could make code more clean:
type
TBaseTest = class
public type
PVector = ^TVector;
TVector = record
...
8
votes
0
answers
273
views
In std::ssize, why return the common_type of decltype(c.size()) and ptrdiff_t?
I wanted a signed type corresponding to std::size (ideally computed from it rather than relying on another definition that could be independent.) Naturally I thought to use std::make_signed_t<std::...
7
votes
0
answers
138
views
Understanding Raku's approach to Exception type hierarchy (or lack thereof)
Raku provides a number of exception types that, on a conceptual level, are subtypes of each other. For example, X::Bind::Slice is conceptually a sub-category of X::Bind. But at an object-hierarchy ...
7
votes
0
answers
126
views
Weird arrows in a Haskell heap profile
When producing a type heap profile (-hy) from a Haskell program, I get these results:
ReaderT
->ReadertT
->>*
(,)
->(#,#)
What is the meaning of the '->' prefix (with one or more '>'...
7
votes
0
answers
2k
views
Extract BigQuery to Newline Delimited JSON without losing types
BigQuery Export Data Docs
Previous Stackoverflow Post on Topic
The bigquery.extract_data() function which extracts data from BigQuery into GCS does not maintain integer or float types. See below for ...
7
votes
1
answer
1k
views
Converting data frame columns in category type in pyspark
I have a data frame df and there I want to convert some columns into category type. Using pandas I can do it like below way:
for col in categorical_collist:
df[col] = df[col].astype('...
7
votes
1
answer
1k
views
One or the other prop type for React component with Typescript
I'm trying to create a Table that renders either by a data prop or you can directly put custom rendered stuff via children. For that I need a type that accepts either data or children.
I found these ...
7
votes
0
answers
1k
views
Importing @types/kendo-ui in correct way without @progress/kendo-ui installed
I want to import the @types/kendo-ui in my project. But even WebStorm not provides me an automatic import function.
Kendo-UI library is already load via <script /> so that I don't need to import ...
7
votes
1
answer
3k
views
Forward declare a Swift class to use it in an Objective-C header
I'm trying to import a Swift class into an Objective-C header file. I know that Project-Swift.h bridge can only be imported into implementation files (.m) but I've got an Objective-C header that needs ...
7
votes
1
answer
152
views
Why does a variance annotation cause this subtyping relation not to be inferred by Scala?
In the code
sealed trait Node[+T]
case class I[C]() extends Node[C => C]
def test[A, B](n: Node[A => B]) = n match {
case i: I[c] =>
val cId: c => c = identity _
...
6
votes
0
answers
272
views
Generic types lose their Generic[T, ...] base class in the .pyi file generated by stubgen
Let's say there is a very simple class that represents a generic stack and hence is inherited from Generic[T] (§1).
from typing import TypeVar, Generic, List
T = TypeVar('T')
class Stack(Generic[T]):...
6
votes
2
answers
526
views
Is it possible to declare a typescript function which works on both numbers and bigints?
In plain untyped Javascript, it's not so hard to write a function which can operate on either numbers or bigints, depending on the arguments which are passed in:
const sumOfSquares = (a,b) => a*a + ...