quox/lib/Quox/Syntax/Universe.idr

34 lines
779 B
Idris

module Quox.Syntax.Universe
import Quox.Pretty
import Data.Fin
import Derive.Prelude
%default total
%language ElabReflection
public export
data Universe = U Nat
%name Universe l
%runElab derive "Universe" [Eq, Ord, Show]
export
PrettyHL Universe where
prettyM (U l) = pure $ hl Free $ pretty l
export
prettyUnivSuffix : Pretty.HasEnv m => Universe -> m (Doc HL)
prettyUnivSuffix (U l) =
ifUnicode (pretty $ pack $ map sub $ unpack $ show l) (pretty l)
where
sub : Char -> Char
sub c = case c of
'0' => ''; '1' => ''; '2' => ''; '3' => ''; '4' => ''
'5' => ''; '6' => ''; '7' => ''; '8' => ''; '9' => ''; _ => c
export %inline
fromInteger : (x : Integer) -> (0 _ : So (x >= 0)) => Universe
fromInteger x = U $ fromInteger x