sext-0.1.0.0: Lists, Texts and ByteStrings with type-encoded length

Safe HaskellNone
LanguageHaskell2010

Data.Sext.Class

Description

Use this only if you need to make some type Sextable.

Synopsis

Documentation

class Sextable a where Source

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

Associated Types

data Sext i a Source

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

type Elem a Source

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

Methods

unsafeCreate :: a -> Sext i a Source

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

For example, an expression like

unsafeCreate "somestring" :: Sext 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 Sext.

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

When implementing new Sextable instances, code this to simply apply the constructor of Sext.

unwrap :: Sext i a -> 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