Formerly NeoVier/elm-eos. Search finds this package by either name.
Get the precision of a Symbol.
fromPrecisionAndCodeString 1 "EOS"
|> Result.map precision
--> Ok 1Get the SymbolCode of a Symbol
import Eos.SymbolCode
fromPrecisionAndCodeString 1 "EOS"
|> Result.map (code >> Eos.SymbolCode.toString)
--> Ok "EOS"Strings and IntsCreate a Symbol from a precision and a String that represents a
SymbolCode. If you already have a SymbolCode,
use fromPrecisionAndCode instead.
import Eos.SymbolCode
fromPrecisionAndCodeString 1 "EOS"
|> Result.map
(\symbol ->
{ precision = precision symbol
, codeString = Eos.SymbolCode.toString (code symbol)
}
)
--> Ok { precision = 1, codeString = "EOS" }
fromPrecisionAndCodeString -1 "EOS"
--> Err (PrecisionError NegativePrecision)
fromPrecisionAndCodeString 1 "eos"
--> Err (SymbolCodeError (Eos.SymbolCode.InvalidCharacters ( 'e', [ 'o', 's' ] )))Create a Symbol from a precision and a SymbolCode.
When creating a Symbol, there are two things we validate: the precision and the symbol code. This type represents that.
Precisions must be >= 0. This type represents the error that can happen when trying to create a Symbol with a negative precision.
You can use this function to convert an Error to a human-readable
String.
A Symbol is what identifies a currency, and is made of a
precisionand a SymbolCode. For example, the symbol1,EOSis a symbol with precision 1, and a symbol code ofEOS.The precision number determines how many decimal digits can be used. In the example above, someone can have 0.1 EOS, but not 0.01 EOS.