module Quox.Name import public Data.SnocList %default total public export data BaseName = UN String -- user-given name private BRepr : Type BRepr = String private %inline brepr : BaseName -> BRepr brepr (UN x) = x export Eq BaseName where (==) = (==) `on` brepr export Ord BaseName where compare = compare `on` brepr export baseStr : BaseName -> String baseStr (UN x) = x export FromString BaseName where fromString = UN public export record Name where constructor MakeName mods : SnocList String base : BaseName private Repr : Type Repr = (SnocList String, BRepr) private %inline repr : Name -> Repr repr x = (x.mods, brepr x.base) export Eq Name where (==) = (==) `on` repr export Ord Name where compare = compare `on` repr export FromString Name where fromString x = MakeName [<] (fromString x) export toDots : Name -> String toDots x = fastConcat $ cast $ map (<+> ".") x.mods :< baseStr x.base