Menu
  • HOME
  • TAGS

Converting 8 byte char array into long

c,arrays,types,shift

The following code is more efficient: unsigned char[word_size] = ...; int64_t num = 0; for ( int i = 0 ; i < sizeof(a) ; i++ ) num = (num << 8) | a[i]; This assumes big endian (highest order byte first) ordering of the bytes in the array. For...

Best practice for handling data types from 3rd party libraries in Haskell?

haskell,types

I am not ready to give a nice list of best practises, but for starters if you want to keep stuff sanely organized, use explicit exports instead of just exporting everything, e.g: module Parser ( parseConfig ) where ... Explicit exports also allow you to reexport your imports, e.g. module...

Derby, Java: Trouble with “CREATE_TYPE” statement

java,eclipse,types,classpath,derby

As politely as I can, may I suggest that if you are uncomfortable with Java's CLASSPATH notion, then writing your own custom data types in Derby is likely to be a challenging project? In the specific case you describe here, one issue that will arise is that your custom Java...

Drools 6.2 How to use ArrayList in declared types?

collections,types,drools,rules,declare

Since ArrayList is a generic collection, Gson is not able to correctly identify the type of the address object when processing the JSON string. The easiest way to accomplish what you are trying to do would be to use an array instead of a ArrayList: declare Person firstName : String...

What's the equivalent of std::is_const for references to const?

c++,types,const

Use remove_reference: #include <string> #include <iostream> #include <type_traits> using namespace std; int main() { int const x = 50; int const& y = x; cout << std::is_const<std::remove_reference<decltype(x)>::type>::value << endl; // 1 cout << std::is_const<std::remove_reference<decltype(y)>::type>::value << endl; // 1 return 0; } See on coliru...

Why Comparison Of two Integer using == sometimes works and sometimes not? [duplicate]

java,types,comparison

The Java Language Specification says that the wrapper objects for at least -128 to 127 are cached and reused by Integer.valueOf(), which is implicitly used by the autoboxing.

Haskell - problems with types

haskell,types

you have to move fac one in: mo08 f = \xx -> fac (if f (xx) then xx else xx * xx) or (if you like) move the xx to the left of the =: mo08 f xx = fac $ if f (xx) then xx else xx * xx...

“conflicting implementations for trait” when trying to be generic

types,rust

The problem with your code is that you have a coherence violation in it, and, very likely, any attempts to fix it would lead to new coherence violations. Coherence rules in Rust are somewhat complex, however, they are based on one principle: you can implement "your" traits for arbitrary types...

Why does using “0” with the ternary operator return the first value?

javascript,types,ternary-operator

"0" is a string of length>0 which is true. Try 0 ? 8 : 10 and see. It will return 10. == does type conversion and hence when you do "0" == false it returns true. When you do 0 == "0" //true It also returns true as again type...

Differences in data types from two approaches

powershell,types

This has nothing to do with the Add-Type cmdlet in particular; it applies to all PowerShell types: PS > (1).GetType().Name Int32 PS > [int].GetType().Name RuntimeType Things like (new-object MyTest) and 1 are instances of specific types. Calling .GetType() on them is returning the type of those instances. Things like [MyTest]...

Convert IntPtr to char** in C#

c#,memory-management,types,type-conversion,dllimport

It should be something like: IntPtr di; int result = afc_read_directory(client, @"C:\", out di); if (di == IntPtr.Zero) { throw new Exception(); } IntPtr di2 = di; while (true) { IntPtr ptr = Marshal.ReadIntPtr(di2); if (ptr == IntPtr.Zero) { break; } string str = Marshal.PtrToStringAnsi(ptr); if (str == string.Empty) {...

How can I change the value stored in local macro from string to numeric in Stata?

types,macros,global,local,stata

If you add =, then Stata will evaluate the expression that defines local date: clear set more off set obs 10 gen y_passed = _n local date = substr("$S_DATE",8,.) display `date' gen start_year = `date' - y_passed list Otherwise, the local just holds a string, but not a number in...

Get list of datatypes with S3 generic function

r,generics,types,r-s3

The first argument of apply must be a matrix-like object (i.e., a matrix, array or data.frame). Otherwise you get this error: apply(1, 1, mean) #Error in apply(1, 1, mean) : dim(X) must have a positive length You are passing a list to apply, which can't work because you tell apply...

Declare variables of a type indicated by a pointer

c++,c,pointers,types,casting

No. C++ is not an interpreted language. "int" has a meaning to the compiler, but at runtime there's nothing which understands "int".

Type Error when using JwtSessionHandler - dart

types,dart,jwt

It happens because JwtSessionHandler expects lookupByUsername function with only one parameter, not lookupByUsernamePassword which has two.

Java infinitely recursive self referential types

java,generics,recursion,types

You'll need a type parameter for the Collection element type, potentially a type parameter for the actual Collection type if you need it, and a type parameter for the values. class SubClass<E, K extends Collection<E>, V> implements Map<K, V> { ... } If you don't need the specific Collection type,...

Type encapsulation in Coq

types,module,encapsulation,coq

Yes. You can define your type inside a module and assign a module type to it: Module Type FOO. Variable t : Type. End FOO. Module Foo : FOO. Inductive typ := | T : typ. Definition t := typ. End Foo. (* This fails *) Check Foo.T. Another possibility...

What types in C++ are enumerated types?

c++,types

From cppreference: An enumeration is a distinct type whose value is restricted to one of several explicitly named constants ("enumerators"). The values of the constants are values of an integral type known as the underlying type of the enumeration. So an example of an enumerated type is any type you...

How to access a Row Type within an Array Type in DB2 SQL PL

arrays,stored-procedures,types,db2,row

You need to declare a temporary variable of the row type and assign array elements to it in a loop: CREATE OR REPLACE PROCEDURE TEST_ARRAY (IN P_ACCT_ARR ACCT_ARR) P1: BEGIN DECLARE i INTEGER; DECLARE v_acct acct; SET i = 1; WHILE i < CARDINALITY(p_acct_arr) DO SET v_acct = p_acct_arr[i]; CALL...

incompatible types required: int found: java.lang.String (basic programming)

java,types

You're reading in a String, but want to save it as Integer/Double. Try this: int num1 = Integer.valueOf(scan.nextLine()); Same goes for Double. Or as OldCurmudgeon mentioned: int num1 = scan.nextInt(); ...

Why doesn't this haskell type signature work?

haskell,types,type-signature

ok this will work: average :: Integral a => [a] -> a average ns = sum ns `div` (fromIntegral $ length ns) please note that div :: Integral a => a -> a -> a so you need Integral a instead of just Num a (which has no division) And...

How do we store text in a list like format in MySQL table cell?

java,mysql,types,jtable

I suggest that this really isn't the way you should design your tables in the database. Since you're using a relational database, I recommend designing your tables like this: For your first table, have columns id fullName cell Then, create another table named items with columns id table_1_id item. When...

Haskell List of List Type Error

haskell,types,ghci

1 is a polymorphic value of type Num a => a. So in [1, [2, 3]], we have [2, 3] :: Num a => [a]; since all list elements must have the same type, we conclude that we must have 1 :: Num a => [a]. That's a bit weird...

c: change variable type without casting

c,types,casting

You could try union - as long as you make sure the types are identical in memory sizes: union convertor { int asInt; float asFloat; }; Then you can assign your int to asFloat (or the other way around if you want to). I use it a lot when I...

How can I get ushort?

c#,sql-server,database,types,sqldatareader

Like the error says, you can cast to ushort: ID = (ushort) reader.GetInt16(2); ...

Julia: Instantiated type parameters

types,julia-lang,type-parameter

It is currently not possible to restrict type parameters like this, though there has been discussion to allow the syntax that you tried up at the top. I believe that the solution that you came up with of checking the type parameter in an inner constructor is considered the best...

Wrong argument kind when using GHC Generics

haskell,types,ghc,typeclass

Don't you mean...? instance (GDefault a, GDefault b) => GDefault (a :+: b) where ... -- ^ ^ ...

Convert byte array to generic value type?

c#,generics,types,stream,buffer

return (TValue)buffer; // here's where I'm stuck Yes, you have just shifted the problem. From not having a Stream.Read<T>() to not having a Convert<T>(byte[]) in the std library. And you would have to call it like Read<int>() anyway so there isn't a direct advantage over BinaryReader.ReadInt32() Now when you want...

neo4j specify data-type during import from csv

types,neo4j,cypher,load-csv

Neo4j uses java primitive types, Strings or arrays of those for property values. There is no date type. So "2015-0104T10:33:44" is a String. Cypher provides couple of functions for type conversion like toFloat, toInt, ... that might help you here. Most folks store millis since epoch for date and time...

Doubts about __bridge, _bridge_retain and _bridge_transfer

ios,objective-c,memory,types,casting

Your problem is that you're using a constant string. This is put straight into the programs memory so the reference is unexpectedly remaining valid despite the fact that it shouldn't. Use something less constant than a constant string and your program will brake like you think.

Scala: generic method using implicit evidence doesn't compile

scala,generics,types,implicit-conversion

You've just told the compiler that types passed to your class as T and S should be equal - you just require an evidence of their equality, which can be used to infer actual T and S correctly when you pass actual types (but not inside generic class itself). It...

How ReSharper chooses whether to show library types in hierarchies inspector?

c#,types,resharper,hierarchy,inspect

Not sure under what circumstances you're getting ReSharper to show types, but the rule of thumb is that the default search scope for Find Usages or Go To Derived Type, etc. is solution scope. So ReSharper will only show usages and derived types that are defined in the current solution....

F# cast / convert custom type to primitive

types,casting,f#,primitive

Your type CT32 is a Discriminated union with one case identifier CT32 of float. It's not an alias to float type so you couldn't just cast it to float. To extract the value from it you can use pattern matching (this is the easiest way). type CT32 = CT32 of...

What is the correct way to implement a stack in Go so that it will store structs?

types,go,stack

The right way in go to implement a stack is simply to use a slice. stack := []*HuffmanTree{} You can push to the stack using append, and pop by writing: v, stack := stack[len(stack)-1], stack[:len(stack)-1] You could encapsulate it into its own type if you prefer, but a slice is...

How can I tell the dartanalyzer what kind of Element the selected object is?

object,syntax,types,dart

You can use as to "cast" in Dart. import 'dart:html'; ... if((querySelector('#username') as InputElement).value!="") ...

Objective-C: Expected a type error

ios,objective-c,types

UILabel, UITextView ... are defined in the UIKit framework, therefore you have to #import <UIKit/UIKit.h> (which then implicitly imports Foundation). You can also use the more modern "module" syntax: @import UIKit; ...

Why do c++ libraries often define their own primitive types?

c++,types,naming-conventions

The reason why this has been done in the past is portability. C and C++ do not make specific guarantees of the size of int, long and short, while library designers often require it. A common solution is to define their own aliases for data types, and changing the definitions...

“Generics add stability to your code by making more of your bugs detectable at compile time.” - Explained in laymen's terms?

debugging,generics,types,compiler-errors

Imagine this scenario: public class Bob(){} public Class Tom(){} List list = new List(); list.Add(new Bob()); list.Add(new Tom()); Tom tom = (Tom)list[0]; //oops wrong index This will fail, but only at run time as a Bob isn't a Tom List<Bob> list = new List<Bob>(); list.Add(new Bob()); Tom tom = list[0];...

Create a type in sqlite

sqlite,types

as far as i know, one solution would be to is to create another table of type B_products and use, a value from main product as foreign key, in table 2. So hence you can link both tables, instead of creating a table inside a table. I think this is...

Why can't I remove the Ord Typeclass from this haskell implementation of Kadane's algorithm?

algorithm,haskell,types,type-inference,type-systems

You cannot remove Ord since you are using functions like < and > and operating them on polymorphic type. See their type: λ> :t (<) (<) :: Ord a => a -> a -> Bool But if you instead limit your polymorphic code to operate only on Int or any...

How do I create a recursive typealias in julia?

recursion,types,julia-lang,type-alias

Dose this work for what you are doing? typealias NestedTuple0{N,T} Tuple{Union(T,N),Union(T,N)} typealias NestedTuple{T} NestedTuple0{NestedTuple0{T},T} Note: I am only able to try this in 036, not 04 An exmple of use: function rnt(p) np = 0.95*p a=rand() <p ? rnt(np) : 1 b=rand() <p ? rnt(np) : 2 (a,b) end x=rnt(1.0)...

Swift binary operator '+' cannot be applied to two CGFloat operands

swift,types,cgfloat

The error message is wrong. The problem is that you are trying to multiply an Int and a CGFloat. Replace: innerY = innerY - CGFloat(gridHeight * row) with: innerY = innerY - gridHeight * CGFloat(row) The answer above is for the current version of your code. For the commented out...

F# generics / function overloading syntax

function,generics,types,f#

This is F#'s embarrassing skeleton in the closet. Try this: > let mapPair f (x,y) = (f x, f y) val mapPair : f:('a -> 'b) -> x:'a * y:'a -> 'b * 'b Fully generic! Clearly, function application and tuples work. Now try this: > let makeList a b...

Composed data type haskell

haskell,types

as the return will wrap it into some monad, you can then get to the parts by deconstructing it directly inside a do block like this: do (b,c) <- solve x y ...

Convert string built bit map (100101) to int value in SQL

mysql,types,data-type-conversion

Try this SELECT CONV( BINARY( '100101' ) , 2, 10 ) It will do the trick. I was inspired by Convert a binary to decimal using MySQL EDIT In fact you can make it even more simple by using just CONV SELECT CONV( '100101' , 2, 10 ) See http://dev.mysql.com/doc/refman/5.5/en/mathematical-functions.html#function_conv...

How to provide a default typeclass for generic types in Scala?

scala,generics,types,typeclass,type-parameter

You can provide an implicit function with the required type: implicit def SeqMonoid[T]: Monoid[Seq[T]] = new Monoid[Seq[T]] { override def op(a: Seq[T], b: Seq[T]): Seq[T] = a ++ b override def id: Seq[T] = Nil } ...

Could not deduce (a ~ Double) with Haskell

haskell,types,ghc,typeclass

The tai parameter is fixed to Double because of your datatype. Change it to data Method a = Ndiv Int | Size a for example, then your function should typecheck, although you'll need a stronger constraint than Num, as cieling requires RealFrac. The type will be function :: RealFrac a...

8 bit int vs 32 bit int on a 32 bit architechture (GCC)

c,gcc,memory,types,compiler-optimization

In most cases, there won't be any memory usage difference because i will never be in memory. i will be stored in a CPU register, and you can't really use one register to store two variables. So i will take one register, uint8 or uint32 doesn't matter. In some rare...

Determine IQuerable column type based on name

linq,types,iqueryable

IQueryable q = ...; if (q.ElementType.GetProperty("PropertyName").PropertyType == typeof(int)) { // PropertyName is an integer property . . . } ...

Expecting a type but actually getting a Maybe a0

json,haskell,types,aeson

The reason for the error is that decode does not always succeed. Its type is decode :: Data a => ByteString -> Maybe a Correspondingly, (decode <$>) :: Data a => IO ByteString -> IO (Maybe a) -- desired type, IO Temperatures, won't unify The type error message gives you...

Mysterious type assertion failure?

reflection,types,go

This can happen if you're using type declaration on numeric types. If you do something like this: type T int64 ... var value interface{} = T(1) and put it into your code, you'll get the exact same error. But if you don't check the kind, but the type, you'll see...

Web Audio- streaming file from server to client

javascript,audio,types,web-audio

I think the issue here is that you're accessing file.length, while file is a Stream object which I don't think have a length property. So what you're doing is basically saying new Int16Array(undefined); and hence the type error. fs.createReadStream is documented here; https://nodejs.org/api/fs.html#fs_fs_createreadstream_path_options You can use the Stream object to...

hsc2hs: Mutate a C struct with Haskell

c,haskell,types,ffi,hsc2hs

This is a complete example of a C program that passes a struct to Haskell then Haskell mutates the values of that struct. It has no outside dependencies. You should be able to copy the code and run it if you have GHC. Hopefully this will serve as a simple,...

Convert String scanner to class type

java,string,types

You can do : String type = scanner.next(); EmployeeType enumType = EmployeeType.valueOf(type); ...

Integer to custom type conversion in Ada

indexing,types,integer,type-conversion,ada

type index is new Integer range 1..50; type table is new Array(index) of expression; You don't need (and can't have) the new keyword in the declaration of table. c: Character; get(c); s: String := " "; s(1) := c; The last two lines can be written as: S: String :=...

F# strange type error message

types,f#,typeerror,discriminated-union

Your error is caused by the fact, that each evaluation that execute in the FSI actually creates a dynamic assembly FSI_XXXX. So in fact, your function that you defined with ExprTree was maybe referring to FSI_0051.ExprTree whereas a function that you defined later and used ExprTree is now referring to...

Deducing value type from iterator for return type of template function

c++,templates,types

You can use std::iterator_traits::value_type: typedef typename std::iterator_traits<Iter>::value_type value_type; As for the function declaration and definition, in old-school C++03 style you could do the following: template<typename Iter> std::pair<typename std::iterator_traits<Iter>::value_type, typename std::iterator_traits<Iter>::value_type> summean(Iter first1, Iter last1) { typedef typename std::iterator_traits<Iter>::value_type value_type; value_type sum = std::accumulate(first1, last1,...

How can I express the type of 'takeWhile for vectors'?

haskell,types,binding,dependent-type

The type you suggest can not be implemented, i.e. it is not inhabited: takeWhileVector :: (a -> Bool) -> Vector a n -> Vector a m Remember that the caller chooses the type variables a,n,m. This means that the caller can use your function as e.g. takeWhileVector :: (a ->...

sql BIT to Java [closed]

java,sql-server,jdbc,types,data-type-conversion

You can call getBoolean directly and let it take care of all the casting/coverting: result.add(rs.getBoolean("columnName")); ...

Javadoc: Do parameter and return need an explicit type description

java,types,javadoc

No, there's no need, the JavaDoc tool parses the Java code and gets the types from there. This article on the Oracle Java site may be useful: How to Write Doc Comments for the Javadoc Tool From the @param part of that article: The @param tag is followed by the...

How much bytes will an int*** be moved forward when incremented? [duplicate]

c,pointers,types,pointer-arithmetic

Incrementing a pointer adds to the memory address the size of the thing the pointer points to. If d is of type int***, it is a pointer to int**. ++d will cause the pointer to move over sizeof(int**) bytes and sizeof(int**) is 4 because it is a pointer. So if...

Golang: Confused about custom types in SQL when sql.DB.Exec

mysql,sql,types,go,custom-type

You implement the Valuer interface for your StatusEnum type as operating on a *StatusEnum. Therefore when you pass one as a parameter to Exec it only makes sense as a pointer as only pointers to StatusEnum implement Value(), requiring a deference inline. You don't have a definition for the EmailList...

What's the difference or relationship between Type and TypeInfo?

.net,reflection,types

From the MSDN docs: A TypeInfo object represents the type definition itself, whereas a Type object represents a reference to the type definition. Getting a TypeInfo object forces the assembly that contains that type to load. In comparison, you can manipulate Type objects without necessarily requiring the runtime to load...

How to remove error of incompatible variable types in LoadLibrary() function?

c++,dll,types,loadlibrary

Try HINSTANCE hInstLibrary = LoadLibrary(L"DLL_tut.dll"); or HINSTANCE hInstLibrary = LoadLibrary(_TEXT("DLL_tut.dll")); The thing is that your project is probably compiled with UNICODE macro defined, which causes LoadLibrary to use LoadLibraryW version, which requires Unicode string as a parameter. ...

Swift 2.0 : infer closure type error

swift,types,init,lazy-initialization

I found two ways to get rid of this error. First, explicitly annotate the property with its type. I find this very strange because Swift is supposed to just infer this from the initialization. lazy var embeddedViewController: CustomViewController = CustomViewController() The second is just to remove the lazy keyword. var...

Should a HttpResponse's status_code attribute be an integer or a string?

python,django,types

You should always pass an integer. HttpResponse('401 Client Error', status=401) As per the HTTP protocol: The Status-Code element is a 3-digit integer result code of the attempt to understand and satisfy the request. ...

Difference between isinstance and type in python [duplicate]

python,python-3.x,types

First check out all the great answers here. type() simply returns the type of an object. Whereas, isinstance(): Returns true if the object argument is an instance of the classinfo argument, or of a (direct, indirect or virtual) subclass thereof. Example: class MyString(str): pass my_str = MyString() if type(my_str) ==...

ArrayList automatically change its type to ArrayList

java,arraylist,types,erasure

Java's generics don't actually change the underlying class or object, they just provide (mostly) compile-time semantics around them. By passing an ArrayList<Integer> into a method expecting an ArrayList (which can hold anything), you're bypassing the compiler's ability to provide you with that type safety. The Java Generics Tutorial explains this,...

Correct type declaration for method returning iterator to C array

c++,arrays,types,iterator,declaration

std::iterator is meant to be used as a base class. From 24.4.2/1: namespace std { template<class Category, class T, class Distance = ptrdiff_t, class Pointer = T*, class Reference = T&> struct iterator { typedef T value_type; typedef Distance difference_type; typedef Pointer pointer; typedef Reference reference; typedef Category iterator_category; };...

why (int) ( 307.03 * 100) = 30702 [duplicate]

php,types,floating-point,int

The float val is stored as 307.02999 or something like that intval just truncate the number, no rounding, hence 30702.

Haskell - Could not deduce … from Context error - OpenGL AsUniform class type

class,haskell,opengl,types,uniform

Try adding -XFlexibleContexts and the constraint, literally, to your existing answer: {-# LANGUAGE FlexibleContexts #-} mvpUnif :: ( GL.UniformComponent a , Num a , Epsilon a , Floating a , AsUniform a , AsUniform (V4 (V4 a)) ) => (GLState a) -> ShaderProgram -> IO () Usually this is the...

SPARQL: How do I List and count each data type in an RDF dataset?

types,count,sparql

Since you've grouped by the datatype of ?o, you know that all the ?o values in a group have the same datatype. You can just sample that to get one of those values, and then take the datatype of it: select (datatype(sample(?o)) as ?datatype) (count(?o) AS ?dTypeCount) where { ?s...

Matlab size function datatype output?

arrays,matlab,types

Try size(data,2). This is pretty basic.

How I can convert array to object in Javascript

javascript,arrays,types,type-conversion

Should be straight forward, just iterate and split on the colon var A = ['"age":"20"','"name":"John"','"email":"[email protected]"']; var O = {}; A.forEach(function(item) { var parts = item.split(':').map(function(x) { return x.trim().replace(/\"/g,'') }); O[parts[0]] = parts[1]; }); document.body.innerHTML = '<pre>' + JSON.stringify(O, null, 4) + '</pre>'; ...

Translate Scheme closure-defining function into Haskell

haskell,recursion,types,scheme,closures

Since you have a recursive type in there, you need to declare it explicitly: data T a = L [a] | F (a -> T a) (+>) (F f) = f unL (L x) = x eat xs x = if x == "vomit" then L $ reverse xs else...

Can the generic type of a generic Java method be used to enforce the type of arguments?

java,generics,types

If I understand your question correctly, you want this: x(10, "x"); to fail at compile time. Now consider doing this: Integer i = 10; String s = "x"; Object o1 = i; Object o2 = s; x(o1, o2); In this case they are both objects - the same type. I...

Node.js Arguments to path.join must be strings but arguments are a path

javascript,node.js,types,sequelize.js

Well, the error is pretty obvious. One of the arguments is not a string. The first one appears to be a number. Just convert it to a string first, e.g. via String: path.join(a, String(b)); ...

Python Uncertainties Unumpy type bug?

python,multidimensional-array,types

First of all, many unumpy objects are basically numpy arrays: >>>arr = unp.uarray([1, 2], [0.01, 0.002]) >>>arr [1.0+/-0.01 2.0+/-0.002] >>>type(arr) <type 'numpy.ndarray'> so you should not be surprised. By the way, ufloat is a function and not a type: >>>x = ufloat(0.20, 0.01) # x = 0.20+/-0.01 >>>print type(x) <class...

How can I express foldr in terms of foldMap for type-aligned sequences?

haskell,types,monoids,type-variables,foldable

I found that this typechecks: {-# LANGUAGE RankNTypes #-} module FoldableTA where import Control.Category import Prelude hiding (id, (.)) class FoldableTA fm where foldMapTA :: Category h => (forall b c . a b c -> h b c) -> fm a b d -> h b d foldrTA ::...

Typescript union type not working

types,typescript,typescript1.4

You will need to do some type checking and casting to handle this scenario: (member: resources.IMember) => { return member.user.id == user.id; if (typeof (member.user) === 'number') { return member.user == user.id; } else { return (<ISimpleUser>member.user).id == user.id; } }).length > 0; Just because you know the possible types...

C# - Get all types that been used in class A

c#,reflection,types

[MyAttribute(new OtherType(TestEnum.EnumValue1))] That's not valid, you have to have a constant in attribute constructors. That matter aside, most of this is easy, if rather long-winded. You can call typeof(MyClass).CustomAttributes.Select(ca => ca.AttributeType) to get the types of attributes, typeof(MyClass).GetFields().Select(fi => fi.FieldType) to get the types of fields, and so on. Union...

Eclipse tells me that Long is not Comparable

java,types,parametric-polymorphism,java-generics

public class LogBookRecord<Long, String> extends Pair<Long, String>{ ^ ^ | | generic type variable declaration (new type names) | generic type arguments That code is equivalent to public class LogBookRecord<T, R> extends Pair<T, R>{ You've simply shadowed the names Long and String with your own type variable names. Since T...

int* const* foo(int x); is a valid C function prototype. How do you “read” this return type?

c++,c,types,grammar

The return type is a pointer to const pointer to int. Read the declaration from right to left, and it will make things much easier. My favourite tutorial for complicated pointer declarations: http://c-faq.com/decl/spiral.anderson.html Some (quite artificial) example: #include <iostream> int* const * foo(int x) { static int* const p =...

python pandas object type dict error when fetching the value

python,dictionary,pandas,types

You could use df.select_dtypes: In [58]: df = pd.DataFrame({'foo':[1,2,3], 'bar':['a','b','c'], 'baz':[1.2,3.4,5.6]}) In [59]: df.select_dtypes(exclude=[np.number]) Out[59]: bar 0 a 1 b 2 c The keys in col_dataType are of type numpy.dtype, not strings: In [67]: [type(item) for item in col_dataType.keys()] Out[67]: [numpy.dtype, numpy.dtype, numpy.dtype] So In [68]: col_dataType[np.dtype('O')] Out[68]: ['bar'] works,...

Required type is same as found type

java,types

There are some scenarios in which Java can't handle the type inference all that well (when one thinks it should). This is one of those scenarios. If you explicitly pass the type to the new invocation, it will compile: Foo<String>.Bar fooBar2 = new Foo<String>().new Bar(); ...

UPDATED - calculating the tuition total

java,syntax,types,resolve

Your main method located at the top of your class: public static void main(String[] args) { Is never closed, you should do something like this: public static void main(String[] args) { } Now your error should be resolved but without something inside your main method your code will probably not...

Correct way to cast a gpointer to a GType

types,macros,glib,gnome

OK I seem to have figured it out myself now.... Firstly, I was using the wrong test in checking for GTYPE_TO_POINTER and GPOINTER_TO_GTYPE since they were the variables I wanted to define the compiler could not find them and the definition was never being made. Secondly, I was using undefined...

Unconstrained type parameters casting

c#,.net,types,casting

The compiler sees the T2 and T identifiers and helpfully informs you that those types seem unrelated. That's absolutely correct, as they have no relation: there are no generic constraints that would assert any relations between them (I'm not saying that would be useful here though :) ). Whether this...

What are the most common bugs in OCaml/Haskell/Scala programs? [closed]

scala,haskell,types,ocaml

This is a partial answer, written for Scala but applicable to other languages. A bug is something happening which was not expected. Thus, to solve bugs, the language should allow to let the user write any expectations and interact with them (proof, synthesis, etc.). There are several ways to address...

Haskell: Type (without boilerplate) for a heterogeneous list of String and/or [String]?

list,haskell,types,existential-type,heterogeneous

This will work for arbitrarily nested lists of strings with a few extension tricks: {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE OverloadedLists #-} import GHC.Exts import Data.String data MyStringListThingy = String String | List [MyStringListThingy] deriving (Eq, Show) instance IsString MyStringListThingy where fromString = String instance IsList...

How to create a record type more than one polymorphic variables

types,polymorphism,ocaml,record

Try type ('a,'b) item = { name:string; quantity:'a; price:'b };; As you can guess, you need to mention every type variable on the left-hand side. You did it for 'a, it's only natural to do it for 'b as well....

How to tell Java that two wildcard types are the same?

java,generics,types

You need to use a type parameter to say that two 'unknown' types are the same. I thought that maybe you should change your method signature from: static <T> void sort(List<T> data, final Key<T, ?> key[], final int dir[]) to static <T,U> void sort(List<T> data, final Key<T,U> key[], final int...