static-text-0.2: Lists, Texts, ByteStrings and Vectors of statically known length

Safe HaskellNone
LanguageHaskell2010

Data.StaticText.Class

Description

Use this module when you need to add an IsStaticText instance to a type.

Synopsis

Documentation

class IsStaticText a where Source #

Class of types which can be assigned a type-level length.

Minimal complete definition

unsafeCreate, unwrap, length, append, replicate, map, take, drop

Associated Types

data Static a (i :: Nat) Source #

Data family which wraps values of the underlying type giving them a type-level length. Static t 6 means a value of type t of length 6.

type Elem a Source #

Basic element type. For IsStaticText [a], this is a.

Methods

unsafeCreate :: a -> Static a i Source #

Simply wrap a value in a Static as is, assuming any length.

For example, an expression like

unsafeCreate "somestring" :: Static 50 String

will typecheck, although the stored length information will not match actual string size. This may result in wrong behaviour of all functions defined for Static.

Use it only when you know what you're doing.

When implementing new IsStaticText instances, code this to simply apply the constructor of StaticText.

unwrap :: Static a i -> a Source #

Forget type-level length, obtaining the underlying value.

length :: a -> Int Source #

append :: a -> a -> a Source #

replicate :: Int -> Elem a -> a Source #

map :: (Elem a -> Elem a) -> a -> a Source #

take :: Int -> a -> a Source #

drop :: Int -> a -> a Source #

Instances

IsStaticText ShortByteString Source #

IsStaticText instance for ShortByteString uses intermediate ByteStrings (pinned) for all modification operations.

IsStaticText ByteString Source # 
IsStaticText Text Source # 

Associated Types

data Static Text (i :: Nat) :: * Source #

type Elem Text :: * Source #

IsStaticText [a] Source # 

Associated Types

data Static [a] (i :: Nat) :: * Source #

type Elem [a] :: * Source #

Methods

unsafeCreate :: [a] -> Static [a] i Source #

unwrap :: Static [a] i -> [a] Source #

length :: [a] -> Int Source #

append :: [a] -> [a] -> [a] Source #

replicate :: Int -> Elem [a] -> [a] Source #

map :: (Elem [a] -> Elem [a]) -> [a] -> [a] Source #

take :: Int -> [a] -> [a] Source #

drop :: Int -> [a] -> [a] Source #

IsStaticText (Vector a) Source # 

Associated Types

data Static (Vector a) (i :: Nat) :: * Source #

type Elem (Vector a) :: * Source #

Methods

unsafeCreate :: Vector a -> Static (Vector a) i Source #

unwrap :: Static (Vector a) i -> Vector a Source #

length :: Vector a -> Int Source #

append :: Vector a -> Vector a -> Vector a Source #

replicate :: Int -> Elem (Vector a) -> Vector a Source #

map :: (Elem (Vector a) -> Elem (Vector a)) -> Vector a -> Vector a Source #

take :: Int -> Vector a -> Vector a Source #

drop :: Int -> Vector a -> Vector a Source #