123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657-------------------------------------------------------------------------- The Agda standard library---- Format strings for Printf and Scanf------------------------------------------------------------------------ {-# OPTIONS --cubical-compatible --safe #-} module Text.Format where open import Data.Maybe.Baseopen import Text.Format.Generic -- Formatted typesopen import Data.Char.Base using (Char)open import Data.Integer.Base using (ℤ)open import Data.Float.Base using (Float)open import Data.Nat.Base using (ℕ)open import Data.String.Base using (String) -------------------------------------------------------------------------- Basic types data ArgChunk : Set where ℕArg ℤArg FloatArg CharArg StringArg : ArgChunk -------------------------------------------------------------------------- Semantics ArgType : (fmt : ArgChunk) → SetArgType ℕArg = ℕArgType ℤArg = ℤArgType FloatArg = FloatArgType CharArg = CharArgType StringArg = String lexArg : Char → Maybe ArgChunklexArg 'd' = just ℤArglexArg 'i' = just ℤArglexArg 'u' = just ℕArglexArg 'f' = just FloatArglexArg 'c' = just CharArglexArg 's' = just StringArglexArg _ = nothing formatSpec : FormatSpecformatSpec .FormatSpec.ArgChunk = ArgChunkformatSpec .FormatSpec.ArgType = ArgTypeformatSpec .FormatSpec.lexArg = lexArg open Format formatSpec public pattern `ℕ = Arg ℕArgpattern `ℤ = Arg ℤArgpattern `Float = Arg FloatArgpattern `Char = Arg CharArgpattern `String = Arg StringArg