Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

polymorphic Bigarray.kind_eq #3962

Closed
vicuna opened this issue Jan 25, 2006 · 2 comments
Closed

polymorphic Bigarray.kind_eq #3962

vicuna opened this issue Jan 25, 2006 · 2 comments

Comments

@vicuna
Copy link

vicuna commented Jan 25, 2006

Original bug ID: 3962
Reporter: @Chris00
Assigned to: @gasche
Status: closed (set by @xavierleroy on 2015-12-11T18:25:35Z)
Resolution: not a bug
Priority: normal
Severity: feature
Version: 3.09.0
Fixed in version: 4.02.0+dev
Category: otherlibs
Related to: #6064

Bug description

It would be nice to have the following function in Bigarray

val kind_eq : ('a, 'b) Bigarray.kind -> ('c, 'd) Bigarray.kind -> bool

While not difficult to write, it requires the use of Obj.magic which is better to avoid in ones code. In the same vein,

val layout_eq : 'a Bigarray.layout -> 'b Bigarray.layout -> bool

would be nice as well (or [is_fortran_layout : 'a Bigarray.layout -> bool] and [is_c_layout : 'a Bigarray.layout -> bool]).

@vicuna
Copy link
Author

vicuna commented Jan 30, 2006

Comment author: @Chris00

Actually more is necessary:
val kind_match :
float:(float -> 'a) ->
complex:(Complex.t -> 'a) ->
int:(int -> 'a) ->
int32:(int32 -> 'a) ->
int64:(int64 -> 'a) ->
nativeint:(nativeint -> 'a) ->
char:(char -> 'a) -> ('b, 'c) Bigarray.kind -> 'b -> 'a
val kind_make :
float:('a -> float) ->
complex:('a -> Complex.t) ->
int:('a -> int) ->
int32:('a -> int32) ->
int64:('a -> int64) ->
nativeint:('a -> nativeint) ->
char:('a -> char) -> ('b, 'c) Bigarray.kind -> 'a -> 'b
val kind_map :
float:(float -> float) ->
complex:(Complex.t -> Complex.t) ->
int:(int -> int) ->
int32:(int32 -> int32) ->
int64:(int64 -> int64) ->
nativeint:(nativeint -> nativeint) ->
char:(char -> char) -> ('a, 'b) Bigarray.kind -> 'a -> 'a

One probably wants to distinguish between float32 and float64, etc. (and not only between OCaml types as above) and to change the names which may not be so good.
I can provide more info on the application if that can serve as a motivation.

@vicuna
Copy link
Author

vicuna commented Jan 9, 2014

Comment author: @gasche

Having this directly in the library is not necessary anymore thanks to #6064. For kind_eq you could even in the equal case build a GADT witness that the types are indeed compatible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants