Movatterモバイル変換


[0]ホーム

URL:


-- |-- An intermediate array representation-- and utilities for its (de)composition.modulePostgreSQLBinary.ArraywhereimportPostgreSQLBinary.Preludehiding(Data)-- |-- A representation of a data serializable to the PostgreSQL array binary format.---- Consists of a list of dimensions, a list of encoded elements,-- a flag specifying, whether it contains any nulls, and an oid.typeData=([Dimension],[Value],Bool,Word32)-- |-- A width and a lower bound.---- Currently the lower bound is only allowed to have a value of @1@.typeDimension=(Word32,Word32)-- |-- An encoded value. 'Nothing' if it represents a @NULL@.typeValue=MaybeByteString-- |-- Access a value of data, if the data represents a single value.asSingleton::Data->MaybeValueasSingleton(dimensions,elements,nulls,oid)=ifnulldimensionsthencaseelementsof[x]->returnxl->$bug$"Unexpected amount of elements: "<>showlelsemzero-- |-- Construct from a non-empty list,-- taking the shared parameters from the first element.fromListUnsafe::[Data]->DatafromListUnsafelist=caselistof(dimensions,values,nulls,oid):tail->((fromIntegral$lengthlist,1):dimensions,values<>foldMapvaluesOftail,nulls,oid)wherevaluesOf(_,x,_,_)=x_->error"Empty list"fromSingleton::Value->Bool->Word32->DatafromSingletonvaluenullableoid=([],[value],nullable,oid)-- |-- Get a list of elements.elements::Data->[Data]elements(dimensions,values,nulls,oid)=dosubvalues<-slicevaluesreturn(subdimensions,subvalues,nulls,oid)where((width,lowerBound),subdimensions)=casedimensionsofh:t->(h,t)_->((0,1),[])chunkSize=ifnullsubdimensionsthen1elseproduct$mapdimensionWidth$subdimensionswheredimensionWidth(x,_)=fromIntegralxslice=foldr(\fgl->caseflof(a,b)->a:gb)(constmzero)$replicate(fromIntegralwidth)(splitAtchunkSize)

[8]ページ先頭

©2009-2025 Movatter.jp