Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Purpose of Data.Vector.Mixed

In Edward Kmett's hybrid-vectors library, there are two main modules: Data.Vector.Hybrid and Data.Vector.Mixed. There's a big article written on the motivation behind the former. The latter is mentioned in passing but lacks any explanation. I'm trying to figure out what use case it is for. I've noticed two things so far:

  1. There is a Mixed typeclass with Typeable constraints. I don't understand the explanation in the haddocks, but it seems like the Typeable constraints must be needed to recover type information or safely cast at some point.
  2. The Vector data type is parameterized over only the underlying MVector. This is different from the Hybrid module where it was parameterized over two vector types plus a tuple.

I would appreciate any helpful insights or (even better) small examples of use cases. Thanks.

like image 722
Andrew Thaddeus Martin Avatar asked Apr 20 '15 13:04

Andrew Thaddeus Martin


People also ask

What happens when you mix types inside a vector?

An atomic vector can only hold values of a single data type. If you put several different types in it, these get coerced to a common type.

Can a vector have multiple data types?

A vector will hold an object of a single type, and only a single type.

Can you mix data type in vector in R?

In R a vector can not contain different types. Everything must e.g. be an integer or everything must be character etc.

How does Cbind work in R?

cbind() function in R Language is used to combine specified Vector, Matrix or Data Frame by columns. deparse. level: This value determines how the column names generated. The default value of deparse.


1 Answers

It's w/in my understanding that theMixed typesclass would enables uses of type-safety functions to be able to parse, merge and fold through a Vector rather than have a concurrent process where each vector is parsed simsimultaneously thus declare M.Vector g v M.Vector h m in order to find a singleton point within these vectors and then using the for MVector do |Stream.length g v && Stream h m to find a singleton within each to fold with this key key :: mergeStreamwith k d -> Stream k i -> Stream d i instance Singleton key where key = Vector.singleton[ v->(v-> MVector v m) -> MVector m] do transversewithkey g v => key.foldlwithkey g h

like image 87
dgomez1092 Avatar answered Sep 28 '22 07:09

dgomez1092