All Projects → xvw → coers

xvw / coers

Licence: MIT license
A small library for coercion to primitive Erlang types.

Programming Languages

erlang
1774 projects

Projects that are alternatives of or similar to coers

TypeConversion
C# library which provides uniform API for conversion between types.
Stars: ✭ 17 (-26.09%)
Mutual labels:  conversion, coercion
bidscoin
BIDScoin converts your source-level neuroimaging data to BIDS
Stars: ✭ 75 (+226.09%)
Mutual labels:  conversion
ReSampler
High quality command-line audio sample rate converter
Stars: ✭ 120 (+421.74%)
Mutual labels:  conversion
tensorflow-tensorrt
Tensorflow to TensorRT Model Converter
Stars: ✭ 30 (+30.43%)
Mutual labels:  conversion
xsampa
X-SAMPA to IPA converter
Stars: ✭ 20 (-13.04%)
Mutual labels:  conversion
Html2Pdf
Convert Html to Pdf in Android
Stars: ✭ 25 (+8.7%)
Mutual labels:  conversion
pesa
A JS money lib whose precision goes up to 11 (and beyond).
Stars: ✭ 38 (+65.22%)
Mutual labels:  conversion
html-to-react
A lightweight library that converts raw HTML to a React DOM structure.
Stars: ✭ 696 (+2926.09%)
Mutual labels:  conversion
mtgsqlive
MTGJSON build scripts to generate alternative data formats
Stars: ✭ 40 (+73.91%)
Mutual labels:  conversion
pngquant
A Python Wrapper of Pngquant
Stars: ✭ 27 (+17.39%)
Mutual labels:  conversion
G711
PCM to G711 Fast Conversions
Stars: ✭ 39 (+69.57%)
Mutual labels:  conversion
bidskit
Utility functions for working with DICOM and BIDS neuroimaging data
Stars: ✭ 52 (+126.09%)
Mutual labels:  conversion
dicomifier
A medical image converter
Stars: ✭ 22 (-4.35%)
Mutual labels:  conversion
cryptoformat
Javascript library to format and display cryptocurrency and money
Stars: ✭ 40 (+73.91%)
Mutual labels:  conversion
physikal
Mirror of Gitlab Repository
Stars: ✭ 33 (+43.48%)
Mutual labels:  conversion
aspose-words-cloud-node
Node.Js library for communicating with the Aspose.Words Cloud API
Stars: ✭ 20 (-13.04%)
Mutual labels:  conversion
CryptionTool
一个CTF+渗透测试工具框架,集成常见加解密,密码、编码转换,端口扫描,字符处理等功能
Stars: ✭ 62 (+169.57%)
Mutual labels:  conversion
rack-params
`Rack::Request.params` validation and type coercion, on Rack.
Stars: ✭ 31 (+34.78%)
Mutual labels:  coercion
converjon
An advanced image conversion server and command line tool.
Stars: ✭ 52 (+126.09%)
Mutual labels:  conversion
InlineDimens
Android dimension types as inline classes with easy conversions.
Stars: ✭ 54 (+134.78%)
Mutual labels:  conversion

coers

Coers is a very small library to provide small coercion on primitive types in Erlang. This library was built essentially for internal tools at derniercri.io

Build & test

$ # Compile the library
$ rebar3 compile
$ # run the tests using eUnit
$ rebar3 eunit

Usage

You can run an erlang shell with coers completely loaded : rebar3 shell :

===> Verifying dependencies...
===> Compiling coers
Erlang/OTP 19 [erts-8.1] [source] [64-bit] [smp:4:4] [async-threads:0] [hipe] [kernel-poll:false] [dtrace]

Eshell V8.1  (abort with ^G)

Basics

Each coercion is wrapped into a special record:

-record(result, {
  succeeded :: boolean(),
  value     :: term()
}).

If a coercion fail, the value member is assigned with a default value and the succeed member is false. If the coersion succeed, the value member becomes the coerced data and the succeed member becomes true.

You can use these 3 combinators to have information about coercion status :

  • -spec succeed(result()) -> boolean().
  • -spec fail(result()) -> boolean().
  • -spec value(result()) -> term().

For example :

1> X = coers:to_int("10").
{result,true,10}
2> Y = coers:to_int("foo").
{result,false,0}
3> [coers:succeed(X), coers:succeed(Y), coers:fail(X), coers:fail(Y)].
[true,false,false,true]
4> [coers:value(X), coers:value(Y)].
[10,0]

Documentation

This page exposes the feature list : http://xvw.github.io/coers/coers.html

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].