sdp-0.2: Simple Data Processing
Copyright(c) Andrey Mulik 2019
LicenseBSD-style
Maintainerwork.a.mulik@gmail.com
Portabilitynon-portable (a lot of GHC extensions)
Safe HaskellTrustworthy
LanguageHaskell2010

SDP.Finite

Description

SDP.Finite provide generalized finite-dimensional index type (:&) based on repa (:.).

Since sdp-0.2, for (:&) available OverloadedLists-based syntactic sugar. For example, instead of the inconvenient es!(ind4 0 1 2 3) or just awful es!(E:&0:&1:&1:&2:&3) you can write: es![0, 1, 2, 3].

Note that OverloadedLists instances requires a strictly defined number of subindexes.

Synopsis
  • data E = E
  • data tail :& head = !tail :& !head
  • type I1 i = E :& i
  • type I2 i = (E :& i) :& i
  • type I3 i = I2 i :& i
  • type I4 i = I3 i :& i
  • type I5 i = I4 i :& i
  • type I6 i = I5 i :& i
  • type I7 i = I6 i :& i
  • type I8 i = I7 i :& i
  • type I9 i = I8 i :& i
  • type I10 i = I9 i :& i
  • type I11 i = I10 i :& i
  • type I12 i = I11 i :& i
  • type I13 i = I12 i :& i
  • type I14 i = I13 i :& i
  • type I15 i = I14 i :& i
  • ind2 :: i -> i -> I2 i
  • ind3 :: i -> i -> i -> I3 i
  • ind4 :: i -> i -> i -> i -> I4 i
  • ind5 :: i -> i -> i -> i -> i -> I5 i
  • ind6 :: i -> i -> i -> i -> i -> i -> I6 i
  • ind7 :: i -> i -> i -> i -> i -> i -> i -> I7 i
  • ind8 :: i -> i -> i -> i -> i -> i -> i -> i -> I8 i
  • ind9 :: i -> i -> i -> i -> i -> i -> i -> i -> i -> I9 i
  • ind10 :: i -> i -> i -> i -> i -> i -> i -> i -> i -> i -> I10 i
  • ind11 :: i -> i -> i -> i -> i -> i -> i -> i -> i -> i -> i -> I11 i
  • ind12 :: i -> i -> i -> i -> i -> i -> i -> i -> i -> i -> i -> i -> I12 i
  • ind13 :: i -> i -> i -> i -> i -> i -> i -> i -> i -> i -> i -> i -> i -> I13 i
  • ind14 :: i -> i -> i -> i -> i -> i -> i -> i -> i -> i -> i -> i -> i -> i -> I14 i
  • ind15 :: i -> i -> i -> i -> i -> i -> i -> i -> i -> i -> i -> i -> i -> i -> i -> I15 i

Generalized index

data E Source #

Service type, that represents zero-dimensional index.

Constructors

E 

Instances

Instances details
IsList E Source # 
Instance details

Defined in SDP.Finite

Associated Types

type Item E #

Methods

fromList :: [Item E] -> E #

fromListN :: Int -> [Item E] -> E #

toList :: E -> [Item E] #

Eq E Source # 
Instance details

Defined in SDP.Finite

Methods

(==) :: E -> E -> Bool #

(/=) :: E -> E -> Bool #

Ord E Source # 
Instance details

Defined in SDP.Finite

Methods

compare :: E -> E -> Ordering #

(<) :: E -> E -> Bool #

(<=) :: E -> E -> Bool #

(>) :: E -> E -> Bool #

(>=) :: E -> E -> Bool #

max :: E -> E -> E #

min :: E -> E -> E #

Read E Source # 
Instance details

Defined in SDP.Finite

Show E Source # 
Instance details

Defined in SDP.Finite

Methods

showsPrec :: Int -> E -> ShowS #

show :: E -> String #

showList :: [E] -> ShowS #

Default E Source # 
Instance details

Defined in SDP.Finite

Methods

def :: E #

Shape E Source # 
Instance details

Defined in SDP.Shape

Associated Types

type DimLast E Source #

type DimInit E Source #

Index E Source # 
Instance details

Defined in SDP.Index

Methods

size :: (E, E) -> Int Source #

sizes :: (E, E) -> [Int] Source #

safeElem :: (E, E) -> E -> E Source #

ordBounds :: (E, E) -> (E, E) Source #

defLimit :: E -> Integer Source #

defaultBounds :: Int -> (E, E) Source #

unsafeIndex :: Int -> E Source #

isEmpty :: (E, E) -> Bool Source #

inBounds :: (E, E) -> E -> InBounds Source #

isOverflow :: (E, E) -> E -> Bool Source #

isUnderflow :: (E, E) -> E -> Bool Source #

inRange :: (E, E) -> E -> Bool Source #

prev :: (E, E) -> E -> E Source #

next :: (E, E) -> E -> E Source #

offset :: (E, E) -> E -> Int Source #

index :: (E, E) -> Int -> E Source #

range :: (E, E) -> [E] Source #

subshape :: (Sub E j, Index (E :|: j)) => (E, E) -> (E :|: j) -> (j, j) Source #

slice :: (Sub E j, ij ~ (E :|: j), Index j) => (E, E) -> ij -> ((ij, ij), (j, j)) Source #

IsList (E :& i) Source # 
Instance details

Defined in SDP.Finite

Associated Types

type Item (E :& i) #

Methods

fromList :: [Item (E :& i)] -> E :& i #

fromListN :: Int -> [Item (E :& i)] -> E :& i #

toList :: (E :& i) -> [Item (E :& i)] #

Enum i => Enum (E :& i) Source # 
Instance details

Defined in SDP.Finite

Methods

succ :: (E :& i) -> E :& i #

pred :: (E :& i) -> E :& i #

toEnum :: Int -> E :& i #

fromEnum :: (E :& i) -> Int #

enumFrom :: (E :& i) -> [E :& i] #

enumFromThen :: (E :& i) -> (E :& i) -> [E :& i] #

enumFromTo :: (E :& i) -> (E :& i) -> [E :& i] #

enumFromThenTo :: (E :& i) -> (E :& i) -> (E :& i) -> [E :& i] #

Shape i => Shape (E :& i) Source # 
Instance details

Defined in SDP.Shape

Associated Types

type DimLast (E :& i) Source #

type DimInit (E :& i) Source #

Methods

fromGIndex :: GIndex (E :& i) -> E :& i Source #

toGIndex :: (E :& i) -> GIndex (E :& i) Source #

rank :: (E :& i) -> Int Source #

consDim :: DimInit (E :& i) -> DimLast (E :& i) -> E :& i Source #

initDim :: (E :& i) -> DimInit (E :& i) Source #

lastDim :: (E :& i) -> DimLast (E :& i) Source #

unconsDim :: (E :& i) -> (DimInit (E :& i), DimLast (E :& i)) Source #

Index i => Index (E :& i) Source # 
Instance details

Defined in SDP.Index

Methods

size :: (E :& i, E :& i) -> Int Source #

sizes :: (E :& i, E :& i) -> [Int] Source #

safeElem :: (E :& i, E :& i) -> (E :& i) -> E :& i Source #

ordBounds :: (E :& i, E :& i) -> (E :& i, E :& i) Source #

defLimit :: (E :& i) -> Integer Source #

defaultBounds :: Int -> (E :& i, E :& i) Source #

unsafeIndex :: Int -> E :& i Source #

isEmpty :: (E :& i, E :& i) -> Bool Source #

inBounds :: (E :& i, E :& i) -> (E :& i) -> InBounds Source #

isOverflow :: (E :& i, E :& i) -> (E :& i) -> Bool Source #

isUnderflow :: (E :& i, E :& i) -> (E :& i) -> Bool Source #

inRange :: (E :& i, E :& i) -> (E :& i) -> Bool Source #

prev :: (E :& i, E :& i) -> (E :& i) -> E :& i Source #

next :: (E :& i, E :& i) -> (E :& i) -> E :& i Source #

offset :: (E :& i, E :& i) -> (E :& i) -> Int Source #

index :: (E :& i, E :& i) -> Int -> E :& i Source #

range :: (E :& i, E :& i) -> [E :& i] Source #

subshape :: (Sub (E :& i) j, Index ((E :& i) :|: j)) => (E :& i, E :& i) -> ((E :& i) :|: j) -> (j, j) Source #

slice :: (Sub (E :& i) j, ij ~ ((E :& i) :|: j), Index j) => (E :& i, E :& i) -> ij -> ((ij, ij), (j, j)) Source #

type Item E Source # 
Instance details

Defined in SDP.Finite

type Item E = E
type DimLast E Source # 
Instance details

Defined in SDP.Shape

type DimLast E = E
type DimInit E Source # 
Instance details

Defined in SDP.Shape

type DimInit E = E
type Item (E :& i) Source # 
Instance details

Defined in SDP.Finite

type Item (E :& i) = i
type DimLast (E :& i) Source # 
Instance details

Defined in SDP.Shape

type DimLast (E :& i) = i
type DimInit (E :& i) Source # 
Instance details

Defined in SDP.Shape

type DimInit (E :& i) = E

data tail :& head Source #

N-dimensional index type. The type (head :& tail) allows working with any finite dimension number.

Constructors

!tail :& !head 

Instances

Instances details
(Item (i' :& i) ~~ i, IsList (i' :& i)) => IsList ((i' :& i) :& i) Source # 
Instance details

Defined in SDP.Finite

Associated Types

type Item ((i' :& i) :& i) #

Methods

fromList :: [Item ((i' :& i) :& i)] -> (i' :& i) :& i #

fromListN :: Int -> [Item ((i' :& i) :& i)] -> (i' :& i) :& i #

toList :: ((i' :& i) :& i) -> [Item ((i' :& i) :& i)] #

IsList (E :& i) Source # 
Instance details

Defined in SDP.Finite

Associated Types

type Item (E :& i) #

Methods

fromList :: [Item (E :& i)] -> E :& i #

fromListN :: Int -> [Item (E :& i)] -> E :& i #

toList :: (E :& i) -> [Item (E :& i)] #

Enum i => Enum (E :& i) Source # 
Instance details

Defined in SDP.Finite

Methods

succ :: (E :& i) -> E :& i #

pred :: (E :& i) -> E :& i #

toEnum :: Int -> E :& i #

fromEnum :: (E :& i) -> Int #

enumFrom :: (E :& i) -> [E :& i] #

enumFromThen :: (E :& i) -> (E :& i) -> [E :& i] #

enumFromTo :: (E :& i) -> (E :& i) -> [E :& i] #

enumFromThenTo :: (E :& i) -> (E :& i) -> (E :& i) -> [E :& i] #

(Eq tail, Eq head) => Eq (tail :& head) Source # 
Instance details

Defined in SDP.Finite

Methods

(==) :: (tail :& head) -> (tail :& head) -> Bool #

(/=) :: (tail :& head) -> (tail :& head) -> Bool #

(Ord tail, Ord head) => Ord (tail :& head) Source # 
Instance details

Defined in SDP.Finite

Methods

compare :: (tail :& head) -> (tail :& head) -> Ordering #

(<) :: (tail :& head) -> (tail :& head) -> Bool #

(<=) :: (tail :& head) -> (tail :& head) -> Bool #

(>) :: (tail :& head) -> (tail :& head) -> Bool #

(>=) :: (tail :& head) -> (tail :& head) -> Bool #

max :: (tail :& head) -> (tail :& head) -> tail :& head #

min :: (tail :& head) -> (tail :& head) -> tail :& head #

(IsList (i' :& i), Item (i' :& i) ~~ i, Read i) => Read (i' :& i) Source # 
Instance details

Defined in SDP.Finite

Methods

readsPrec :: Int -> ReadS (i' :& i) #

readList :: ReadS [i' :& i] #

readPrec :: ReadPrec (i' :& i) #

readListPrec :: ReadPrec [i' :& i] #

(IsList (i' :& i), Item (i' :& i) ~~ i, Show i) => Show (i' :& i) Source # 
Instance details

Defined in SDP.Finite

Methods

showsPrec :: Int -> (i' :& i) -> ShowS #

show :: (i' :& i) -> String #

showList :: [i' :& i] -> ShowS #

(Default d, Default d') => Default (d :& d') Source # 
Instance details

Defined in SDP.Finite

Methods

def :: d :& d' #

(Shape i, Enum i, Bounded i, Shape (i' :& i)) => Shape ((i' :& i) :& i) Source # 
Instance details

Defined in SDP.Shape

Associated Types

type DimLast ((i' :& i) :& i) Source #

type DimInit ((i' :& i) :& i) Source #

Methods

fromGIndex :: GIndex ((i' :& i) :& i) -> (i' :& i) :& i Source #

toGIndex :: ((i' :& i) :& i) -> GIndex ((i' :& i) :& i) Source #

rank :: ((i' :& i) :& i) -> Int Source #

consDim :: DimInit ((i' :& i) :& i) -> DimLast ((i' :& i) :& i) -> (i' :& i) :& i Source #

initDim :: ((i' :& i) :& i) -> DimInit ((i' :& i) :& i) Source #

lastDim :: ((i' :& i) :& i) -> DimLast ((i' :& i) :& i) Source #

unconsDim :: ((i' :& i) :& i) -> (DimInit ((i' :& i) :& i), DimLast ((i' :& i) :& i)) Source #

Shape i => Shape (E :& i) Source # 
Instance details

Defined in SDP.Shape

Associated Types

type DimLast (E :& i) Source #

type DimInit (E :& i) Source #

Methods

fromGIndex :: GIndex (E :& i) -> E :& i Source #

toGIndex :: (E :& i) -> GIndex (E :& i) Source #

rank :: (E :& i) -> Int Source #

consDim :: DimInit (E :& i) -> DimLast (E :& i) -> E :& i Source #

initDim :: (E :& i) -> DimInit (E :& i) Source #

lastDim :: (E :& i) -> DimLast (E :& i) Source #

unconsDim :: (E :& i) -> (DimInit (E :& i), DimLast (E :& i)) Source #

(Index i, Enum i, Bounded i, Index (i' :& i)) => Index ((i' :& i) :& i) Source # 
Instance details

Defined in SDP.Index

Methods

size :: ((i' :& i) :& i, (i' :& i) :& i) -> Int Source #

sizes :: ((i' :& i) :& i, (i' :& i) :& i) -> [Int] Source #

safeElem :: ((i' :& i) :& i, (i' :& i) :& i) -> ((i' :& i) :& i) -> (i' :& i) :& i Source #

ordBounds :: ((i' :& i) :& i, (i' :& i) :& i) -> ((i' :& i) :& i, (i' :& i) :& i) Source #

defLimit :: ((i' :& i) :& i) -> Integer Source #

defaultBounds :: Int -> ((i' :& i) :& i, (i' :& i) :& i) Source #

unsafeIndex :: Int -> (i' :& i) :& i Source #

isEmpty :: ((i' :& i) :& i, (i' :& i) :& i) -> Bool Source #

inBounds :: ((i' :& i) :& i, (i' :& i) :& i) -> ((i' :& i) :& i) -> InBounds Source #

isOverflow :: ((i' :& i) :& i, (i' :& i) :& i) -> ((i' :& i) :& i) -> Bool Source #

isUnderflow :: ((i' :& i) :& i, (i' :& i) :& i) -> ((i' :& i) :& i) -> Bool Source #

inRange :: ((i' :& i) :& i, (i' :& i) :& i) -> ((i' :& i) :& i) -> Bool Source #

prev :: ((i' :& i) :& i, (i' :& i) :& i) -> ((i' :& i) :& i) -> (i' :& i) :& i Source #

next :: ((i' :& i) :& i, (i' :& i) :& i) -> ((i' :& i) :& i) -> (i' :& i) :& i Source #

offset :: ((i' :& i) :& i, (i' :& i) :& i) -> ((i' :& i) :& i) -> Int Source #

index :: ((i' :& i) :& i, (i' :& i) :& i) -> Int -> (i' :& i) :& i Source #

range :: ((i' :& i) :& i, (i' :& i) :& i) -> [(i' :& i) :& i] Source #

subshape :: (Sub ((i' :& i) :& i) j, Index (((i' :& i) :& i) :|: j)) => ((i' :& i) :& i, (i' :& i) :& i) -> (((i' :& i) :& i) :|: j) -> (j, j) Source #

slice :: (Sub ((i' :& i) :& i) j, ij ~ (((i' :& i) :& i) :|: j), Index j) => ((i' :& i) :& i, (i' :& i) :& i) -> ij -> ((ij, ij), (j, j)) Source #

Index i => Index (E :& i) Source # 
Instance details

Defined in SDP.Index

Methods

size :: (E :& i, E :& i) -> Int Source #

sizes :: (E :& i, E :& i) -> [Int] Source #

safeElem :: (E :& i, E :& i) -> (E :& i) -> E :& i Source #

ordBounds :: (E :& i, E :& i) -> (E :& i, E :& i) Source #

defLimit :: (E :& i) -> Integer Source #

defaultBounds :: Int -> (E :& i, E :& i) Source #

unsafeIndex :: Int -> E :& i Source #

isEmpty :: (E :& i, E :& i) -> Bool Source #

inBounds :: (E :& i, E :& i) -> (E :& i) -> InBounds Source #

isOverflow :: (E :& i, E :& i) -> (E :& i) -> Bool Source #

isUnderflow :: (E :& i, E :& i) -> (E :& i) -> Bool Source #

inRange :: (E :& i, E :& i) -> (E :& i) -> Bool Source #

prev :: (E :& i, E :& i) -> (E :& i) -> E :& i Source #

next :: (E :& i, E :& i) -> (E :& i) -> E :& i Source #

offset :: (E :& i, E :& i) -> (E :& i) -> Int Source #

index :: (E :& i, E :& i) -> Int -> E :& i Source #

range :: (E :& i, E :& i) -> [E :& i] Source #

subshape :: (Sub (E :& i) j, Index ((E :& i) :|: j)) => (E :& i, E :& i) -> ((E :& i) :|: j) -> (j, j) Source #

slice :: (Sub (E :& i) j, ij ~ ((E :& i) :|: j), Index j) => (E :& i, E :& i) -> ij -> ((ij, ij), (j, j)) Source #

type Item ((i' :& i) :& i) Source # 
Instance details

Defined in SDP.Finite

type Item ((i' :& i) :& i) = i
type Item (E :& i) Source # 
Instance details

Defined in SDP.Finite

type Item (E :& i) = i
type DimLast ((i' :& i) :& i) Source # 
Instance details

Defined in SDP.Shape

type DimLast ((i' :& i) :& i) = i
type DimLast (E :& i) Source # 
Instance details

Defined in SDP.Shape

type DimLast (E :& i) = i
type DimInit ((i' :& i) :& i) Source # 
Instance details

Defined in SDP.Shape

type DimInit ((i' :& i) :& i) = i' :& i
type DimInit (E :& i) Source # 
Instance details

Defined in SDP.Shape

type DimInit (E :& i) = E

Type synonyms

type I1 i = E :& i Source #

1-dimensional index ((E :& i) without TypeOperators).

type I2 i = (E :& i) :& i Source #

2-dimensional index

type I3 i = I2 i :& i Source #

3-dimensional index

type I4 i = I3 i :& i Source #

4-dimensional index

type I5 i = I4 i :& i Source #

5-dimensional index

type I6 i = I5 i :& i Source #

6-dimensional index

type I7 i = I6 i :& i Source #

7-dimensional index

type I8 i = I7 i :& i Source #

8-dimensional index

type I9 i = I8 i :& i Source #

9-dimensional index

type I10 i = I9 i :& i Source #

10-dimensional index

type I11 i = I10 i :& i Source #

11-dimensional index

type I12 i = I11 i :& i Source #

12-dimensional index

type I13 i = I12 i :& i Source #

13-dimensional index

type I14 i = I13 i :& i Source #

14-dimensional index

type I15 i = I14 i :& i Source #

15-dimensional index

Old constructors

ind2 :: i -> i -> I2 i Source #

2-dimensional index constructor.

ind3 :: i -> i -> i -> I3 i Source #

3-dimensional index constructor.

ind4 :: i -> i -> i -> i -> I4 i Source #

4-dimensional index constructor.

ind5 :: i -> i -> i -> i -> i -> I5 i Source #

5-dimensional index constructor.

ind6 :: i -> i -> i -> i -> i -> i -> I6 i Source #

6-dimensional index constructor.

ind7 :: i -> i -> i -> i -> i -> i -> i -> I7 i Source #

7-dimensional index constructor.

ind8 :: i -> i -> i -> i -> i -> i -> i -> i -> I8 i Source #

8-dimensional index constructor.

ind9 :: i -> i -> i -> i -> i -> i -> i -> i -> i -> I9 i Source #

9-dimensional index constructor.

ind10 :: i -> i -> i -> i -> i -> i -> i -> i -> i -> i -> I10 i Source #

10-dimensional index constructor.

ind11 :: i -> i -> i -> i -> i -> i -> i -> i -> i -> i -> i -> I11 i Source #

11-dimensional index constructor.

ind12 :: i -> i -> i -> i -> i -> i -> i -> i -> i -> i -> i -> i -> I12 i Source #

12-dimensional index constructor.

ind13 :: i -> i -> i -> i -> i -> i -> i -> i -> i -> i -> i -> i -> i -> I13 i Source #

13-dimensional index constructor.

ind14 :: i -> i -> i -> i -> i -> i -> i -> i -> i -> i -> i -> i -> i -> i -> I14 i Source #

14-dimensional index constructor.

ind15 :: i -> i -> i -> i -> i -> i -> i -> i -> i -> i -> i -> i -> i -> i -> i -> I15 i Source #

15-dimensional index constructor.