nbt alternatives and similar packages
Based on the "Data" category.
Alternatively, view nbt alternatives based on common mentions on social networks and blogs.
-
semantic-source
Parsing, analyzing, and comparing source code across many languages -
text
Haskell library for space- and time-efficient operations over Unicode text. -
code-builder
Packages for defining APIs, running them, generating client code and documentation. -
compendium-client
Mu (μ) is a purely functional framework for building micro services. -
cassava
A CSV parsing and encoding library optimized for ease of use and high performance -
resource-pool
A high-performance striped resource pooling implementation for Haskell -
primitive
This package provides various primitive memory-related operations. -
discrimination
Fast linear time sorting and discrimination for a large class of data types -
reflection
Reifies arbitrary Haskell terms into types that can be reflected back into terms -
dependent-map
Dependently-typed finite maps (partial dependent products) -
dependent-sum
Dependent sums and supporting typeclasses for comparing and displaying them -
streaming
An optimized general monad transformer for streaming applications, with a simple prelude of functions -
orgmode-parse
Attoparsec parser combinators for parsing org-mode structured text! -
text-icu
This package provides the Haskell Data.Text.ICU library, for performing complex manipulation of Unicode text. -
scientific
Arbitrary-precision floating-point numbers represented using scientific notation
Clean code begins in your IDE with SonarLint
Do you think we are missing an alternative of nbt or a related project?
README
nbt
Usage
The nbt
library gives you a data type NBT
along with types to all the tags in an NBT's substructure. The library works by providing an Serialize
instance for this NBT
type as well as all the substructure tags by relation.
For the most basic usage, you'll need to read a NBT file in as a ByteString
, decompress it, and then feed it in as a strict ByteString
to decode
:
import qualified Codec.Compression.GZip as GZip
import qualified Data.ByteString.Lazy as BL
import Data.NBT
import Data.Serialize
main :: IO ()
main = do
-- Grab a raw lazy ByteString from some NBT file
compressedRaw <- BL.readFile "level.dat"
-- NBT files are GZip'd when stored, decompress it and make it strict
let raw = BL.toStrict $ GZip.decompress compressedRaw
-- Use the nbt library's Serialize instance to obtain an NBT type,
-- provided nothing goes wrong!
let shouldBeNBT = (decode raw :: Either String NBT)
-- Did we actually just read an NBT file?
-- If so, print NBT and then write it back out to file.
-- Otherwise, show the error.
case shouldBeNBT of
Right nbt -> print nbt >> (BL.writeFile "anotherlevel.dat" $ prep nbt)
Left err -> putStrLn err
where prep n = GZip.compress $ BL.fromChunks [encode n]
This NBT
type has the following structure: Text
is used for the name of a
tag while NbtContents
is used for the tag's payload.
data NBT = NBT Text NbtContents deriving (Show,Eq)
data NbtContents
= ByteTag Int8
| ShortTag Int16
| IntTag Int32
| LongTag Int64
| FloatTag Float
| DoubleTag Double
| ByteArrayTag (UArray Int32 Int8)
| StringTag T.Text
| ListTag (Array Int32 NbtContents)
| CompoundTag [NBT]
| IntArrayTag (UArray Int32 Int32)
| LongArrayTag (UArray Int32 Int64)
deriving (Show, Eq)