HORIZON HASKELLDocslts/ghc-9.14.x99ffbb82026-10-19Search packagesCtrl K
Theme: |

GHC 9.14.1 · lts/ghc-9.14.x · 99ffbb8 · 2026-10-19

Moduleweb3-ethereum-1.1.0.1Haskell2010

Network.Ethereum.Unit

Ethereum has a metric system of denominations used as units of ether. Each denomination has its own unique name (some bear the family name of seminal figures playing a role in evolution of computer science and cryptoeconomics). The smallest denomination aka base unit of ether is called Wei. Below is a list of the named denominations and their value in Wei. Following a common (although somewhat ambiguous) pattern, ether also designates a unit (of 1e18 or one quintillion Wei) of the currency. Note that the currency is not called Ethereum as many mistakenly think, nor is Ethereum a unit.

In Haskell the Ethereum unit system presented as set of types: Wei, Szabo, Finney, etc. They are members of Unit typeclass. Also available standart Show, Read, Num operations over Ethereum units.

> let x = 1.2 :: Ether
> toWei x
1200000000000000000

> let y = x + 2
> y
3.20 ether

> let z = 15 :: Szabo
> y + z

interactive:6:5: error:
   • Couldn't match type ‘Network.Ethereum.Unit.U4’
                   with ‘Network.Ethereum.Unit.U6’
     Expected type: Ether
     Actual type: Szabo
Contents
  1. The Unit type class
  2. Ethereum value metrics
Synopsis

The Unit type class

classclass (Read a, Show a, UnitSpec a, Fractional a) => Unit a where

Ethereum value unit

Methods

Instances1Unit
  • UnitSpec a => Unit (Value a)Defined in web3-ethereum-1.1.0.1 · Network.Ethereum.Unit

Ethereum value metrics