Debian Codegraph @

src/Text/Printf.agda

raw
1 ------------------------------------------------------------------------
2 -- The Agda standard library
3 --
4 -- Printf
5 ------------------------------------------------------------------------
6
7 {-# OPTIONS --cubical-compatible --safe #-}
8
9 module Text.Printf where
10
11 open import Data.String.Base using (String; fromChar; concat)
12 open import Function.Base using (id)
13
14 import Data.Integer.Show as ℤ
15 import Data.Float.Base as Float
16 import Data.Nat.Show as ℕ
17
18 open import Text.Format as Format hiding (Error)
19 open import Text.Printf.Generic
20
21 printfSpec : PrintfSpec formatSpec String
22 printfSpec .PrintfSpec.renderArg ℕArg = ℕ.show
23 printfSpec .PrintfSpec.renderArg ℤArg = ℤ.show
24 printfSpec .PrintfSpec.renderArg FloatArg = Float.show
25 printfSpec .PrintfSpec.renderArg CharArg = fromChar
26 printfSpec .PrintfSpec.renderArg StringArg = id
27 printfSpec .PrintfSpec.renderStr = id
28
29 module Printf = Type formatSpec
30 open Printf public hiding (map)
31 open Render printfSpec public renaming (printf to gprintf)
32
33 printf : (fmt : String) → Printf (lexer fmt) String
34 printf fmt = Printf.map (lexer fmt) concat (gprintf fmt)