Source

blaze-textual / Blaze / Text / Double.hs

Full commit
-- Module:      Blaze.Text.Double
-- Copyright:   (c) 2011 MailRank, Inc.
-- License:     BSD3
-- Maintainer:  Bryan O'Sullivan <bos@mailrank.com>
-- Stability:   experimental
-- Portability: portable
--
-- Efficiently serialize a Double as a lazy 'L.ByteString'.

module Blaze.Text.Double
    (
      float
    , double
    ) where

import Blaze.ByteString.Builder (Builder, fromByteString)
import Data.Double.Conversion.ByteString (toShortest)

float :: Float -> Builder
float = double . realToFrac

double :: Double -> Builder
double f = fromByteString (toShortest f)