Skip to main content
Filter by
Sorted by
Tagged with
-1 votes
1 answer
65 views

I’m really confused about what polymorphism in OOP actually means. Everyone explains it differently, and I’m not sure which definition is correct: In some places, polymorphism is explained as dynamic ...
Ado's user avatar
  • 55
0 votes
1 answer
54 views

I am writing functions manipulating binary matrices and I would like to make them parametric where possible. How can I create structs that have, for example, a matrix and an element of the column ...
Joel Wallman's user avatar
0 votes
1 answer
433 views

Swift newbie here, please be kind! How can I convert this SwiftUI view into a version that accepts different types of items as input? I have this view in my iOS app: struct EditMeshType: View { ...
BaldNomad's user avatar
1 vote
0 answers
107 views

This works > bimap succ succ (1, 'a') (2, 'b') but this doesn't > both f = bimap f f > both succ (1, 'a') <interactive>:11:12: error: • No instance for (Num Char) arising from the ...
Enlico's user avatar
  • 30.3k
8 votes
1 answer
274 views

I declared two functions using the 'forall' quantifier. The first of them has a quantifier with all generic type parameters before the signature. The second has quantifiers in place of the first usage ...
Valentyn Zakharenko's user avatar
0 votes
1 answer
59 views

My context Any node has a support....but this support can be a wall or a pylon (actually there are about 7 different types of support) Important: the column type_support is saying which table to ...
floupinette's user avatar
0 votes
1 answer
66 views

First, setup interface IRequirement { } interface ITarget { ICollection<IRequirement> Requirements { get; set; } } interface IRequirementHandler<TRequirement, TTarget> where ...
mhDuke's user avatar
  • 148
2 votes
0 answers
45 views

I found 2 different type like: type Pair = <Head, Tail> (head: Head) => (tail: Tail) => {head: Head; tail: Tail;} type Pair <Head, Tail> = (head: Head) => (tail: Tail) => {...
ypa y yhm's user avatar
  • 219
1 vote
0 answers
448 views

I have a struct that has quite a few different fields. Initially, I can use parametric typing for all of the fields. For example: struct MyStruct{TF, TI, TB} a::TF b::TF c::Array{TF, 2} ...
cardoza2's user avatar
  • 185
-1 votes
2 answers
110 views

I have three classes called Animal, Cat and Dog where Cat and Dog inherit from Animal: public class Animal { public void Talk() { Console.WriteLine("Parent"); } } public ...
IMm0rtal's user avatar
  • 111
-1 votes
2 answers
407 views

I'm getting acquainted with the Polymorphism of OOP while making a game in Unity. I try to use an interface that will take part in a damage system. Here is the interface code: using System.Collections;...
BSN's user avatar
  • 1
0 votes
2 answers
334 views

I am trying to call the method .enumerate() on an instance of a type which conforms to the protocol Sequence. According to Apple's documentation, this should be correct, since .enumerate is part of ...
Myridium's user avatar
  • 924
0 votes
4 answers
839 views

This is me probably going off what is considered idiomatic in Julia, as I am clearly abusing parametric types (generic types instead of hardcoded ones) but I am struggling to understand why this doesn'...
DMeneses's user avatar
  • 159
2 votes
1 answer
112 views

I am having some issues understanding the concept of parametric constructors in Julia. I am looking at the standard example in the Julia docs: struct Point{T<:Real} x::T y::T end To my ...
TylerD's user avatar
  • 469
0 votes
1 answer
70 views

I'm trying to declare a record type that has two entries, one named id that is a string, and another named algorithm that can be any function. According to what I've investigated, I need to use ...
NPN328's user avatar
  • 1,962
0 votes
0 answers
55 views

I'm writing some tests and mocks for my product but I'm having troubles with generic parameters and constraints... enum ApiResult<Success, Failure> where Failure: Error { case success(...
jbat's user avatar
  • 23
1 vote
1 answer
60 views

As I understand now from Array as object I have to use parametric object, because using non-parametric Logtalk objects implies that I have to use assert i.e. any change/set rewrites the whole array. ...
sten's user avatar
  • 7,546
2 votes
0 answers
399 views

I'm trying to do something like that: internal class ConcreteLinkedItem : GenericLinkedItem<ConcreteLinkedItem> { //Specific methods which use GenericLinkedItem } internal class ...
Valentin Vasilev's user avatar
3 votes
1 answer
170 views

I have defined a buggy function: let first : 'a -> 'b -> 'a = fun x y -> y ;; (* Result: val first : 'a -> 'a -> 'a = <fun> *) The compiler accepts it and changes the type from '...
Oleg Dats's user avatar
  • 4,143
2 votes
0 answers
381 views

My situation is similar to that of the Vertical Attribute Mapping examples covered in the SQLAlchemy documentation. However, the column names and values are stored in a JSON field as a dictionary. The ...
CaffeinatedMike's user avatar
0 votes
2 answers
183 views

The answer is: (a -> b) -> (c -> d -> a) -> c -> d -> b But I don't know how to get there.
David Vives's user avatar
3 votes
1 answer
282 views

I want to restrict the parametric return type (a Vector of something) of a function. Say I have a function f defined as follows: julia> function f()::Vector{Real} return [5] end f ...
MetaColon's user avatar
  • 2,871
3 votes
1 answer
100 views

During some development using cubical-agda, I noticed (and later checked) that my current goal, if proven would also imply such theorem: parametric? : ∀ ℓ → Type (ℓ-suc ℓ) parametric? ℓ = (f : {A : ...
MJG's user avatar
  • 73
1 vote
3 answers
248 views

In one of the solutions on codewars I've met the following expression: join bimap where join :: Monad m => m (m a) -> m a, and bimap :: Bifunctor p => (a -> b) -> (c -> d) -> p ...
Karen Fisher's user avatar
6 votes
3 answers
746 views

I am creating a turn based game. I want to define a datatype that encodes one type out of many possible types. Here is the motivating example: I have defined a Turn type using GADTs, so the type of ...
MooseOnTheRocks's user avatar
5 votes
4 answers
590 views

I'm new to Haskell and reading Haskell from first principles. BTW this question is general not related to this book, I have taken following question as example In Chapter 10, Section 10.5, Q 5, part f ...
hanan's user avatar
  • 1,929
2 votes
2 answers
268 views

I'm trying to produce a typed Racket procedure that for some type A, takes a Tree, and a function from two As to an A, another parameter of type A, and returns a value of type A. I'm not very familiar ...
Isaac Wasserman's user avatar
0 votes
1 answer
38 views

I have gender class with Male and Female as my parametric types of class I am using following hierarchy: #ifndef __GENDER_H #define __GENDER_H #include <string> using namespace std; // Forward ...
suman's user avatar
  • 97
4 votes
2 answers
330 views

For a type with parametrically typed fields like: struct Point{T <: AbstractFloat} x::T y::T end How to make an outer constructor that creates default values with the desired types? For ...
BaliSun's user avatar
  • 43
2 votes
3 answers
542 views

This code fails to compile: pub trait ToVec<T> { fn to_vec(self) -> Vec<T>; } impl<I, T> ToVec<T> for I where I: Iterator<Item = T>, { fn to_vec(self) -&...
apilat's user avatar
  • 1,530
0 votes
1 answer
298 views

I've defined a trait as follows: trait Readable<E> { fn read_u8(&mut self) -> Result<u8, E>; fn read_u16be(&mut self) -> Result<u16, E>; } The idea is to ...
puritii's user avatar
  • 1,359
2 votes
1 answer
2k views

In a function generic on T, how can I properly create and initialize a variable of type T in safe (or unsafe) Rust? T can be anything. What is the idiomatic way of doing such thing? fn f<T>() { ...
Özgür Murat Sağdıçoğlu's user avatar
76 votes
2 answers
30k views

AsRef documentation writes Used to do a cheap reference-to-reference conversion. I understand reference-to-reference part what does it mean by cheap? I hope it has nothing to do with complexity ...
HardFork's user avatar
  • 1,153
1 vote
1 answer
347 views

How to send generic T? I try to send a generic T to another thread but I'm getting: error[E0308]: mismatched types --> src/main.rs:23:22 | 23 | t1.merge(Element(vec![3])); | ...
Anunaki's user avatar
  • 923
0 votes
1 answer
35 views

So if I wanted a method to be common for 3 child classes, like this: public void commonForAllAnimals(Animal animal) { // this method exists in subclasses that I need animal.foo(); // only in Dog ...
developer10's user avatar
  • 1,500
2 votes
3 answers
128 views

StructA implements From<StructB>, and StructB implements From<S>. How can I generically implement a 'shortcut' Into<StructA> for S or From<S> for StructA? If this is a bad idea,...
wisha's user avatar
  • 743
2 votes
1 answer
1k views

I want to work with rings, so I have a trait RingOps and I want float to be a part of it. I think float implements each supertype so deriving would be great, but if not, how to do this? trait RingOps: ...
rausted's user avatar
  • 959
3 votes
1 answer
345 views

I have a function f op = (op 1 2, op 1.0 2.0), which is required to work like this: f (+) (3, 3.0) But without declaring the type of f it works like this: f (+) (3.0, 3.0) And I'm struggling with ...
darya's user avatar
  • 33
8 votes
3 answers
4k views

I have a struct NotificationOption and another struct NotificationOption2 as well as an implementation for From<NotificationOption> for NotificationOption2. I'm would like to convert Vec<...
Avba's user avatar
  • 15.4k
3 votes
1 answer
123 views

Let's look at these functions' types for example: :t traverse traverse :: (Applicative f, Traversable t) => (a -> f b) -> t a -> f (t b) :t id id :: a -> a They have no concrete ...
Evg's user avatar
  • 3,090
2 votes
2 answers
1k views

For a function like this: fn generate_even(a: i32, b: i32) -> impl Iterator<Item = i32> { (a..b).filter(|x| x % 2 == 0) } I want to make it generic, instead of the concrete type i32 I ...
tipograf ieromonah's user avatar
0 votes
2 answers
100 views

I would like to implement a Generic method inside a CommonInterface to implement it with different parameters and return Type. Therefore I have: public interface Common { public <T, N> T call(...
CoderJammer's user avatar
0 votes
2 answers
95 views

To clarify what I mean, my issue is with a simulated annealing problem where I want to find the theta that gives me the max area of a shape: def Area(theta): #returns area def SimAnneal(space,func,...
PythonMan1029's user avatar
0 votes
2 answers
157 views

So I am working with .NET Core, and I am working out some data contracts that need to be expandable, to this end, I intend to use parametric polymorphism aka generics. Now, My sample interfaces and ...
rasmus91's user avatar
  • 3,223
0 votes
1 answer
113 views

The following code produces the titular error: (: f (∀ (a) (-> [#:x a] (U Integer a)))) (define (f #:x [x #f]) (or x 0)) (f #:x 3) OK, but (f #:x (cast 3 Integer)) still produces the same error. ...
0xnick1chandoke's user avatar
1 vote
1 answer
108 views

On page 349 paragraph 5 of A Theory of Type Polymorphism in Programming, Milner says, For us, the polymorphism present in a program is a natural outgrowth of the primitive polymorphic operators which ...
Conor Quinn's user avatar
0 votes
1 answer
78 views

Trying to implement a generic Vec implementing the std::ops::Add trait. I want the implementation to automatically convert the underlying type of the vector on addition so I can do something like this:...
Luke Skywalker's user avatar
0 votes
1 answer
129 views

Using RankNTypes one can enforce various kinds of parametricity. For example, A id :: A: newtype A = A { unA :: forall a. a -> a } But how about cases where we only care about the parametricity of ...
SEC's user avatar
  • 799
2 votes
1 answer
52 views

When you define parametric classes you can only use a fixed number of parameters. class Container<T> { ... } However, if you want to create, say, a Map with multiple values. You must use a ...
user avatar
3 votes
2 answers
104 views

I'm trying to implement various things in pure lambda calculus with Haskell. Everything works fine {-# LANGUAGE RankNTypes #-} type List a = forall b. (a -> b -> b) -> b -> b empty :: ...
Marvin's user avatar
  • 1,932

1
2 3 4 5