2021-07-20 16:05:19 -04:00
|
|
|
module Quox.Syntax.Universe
|
|
|
|
|
|
|
|
import Quox.Pretty
|
|
|
|
|
|
|
|
import Data.Fin
|
2023-03-02 13:52:32 -05:00
|
|
|
import Derive.Prelude
|
2021-07-20 16:05:19 -04:00
|
|
|
|
|
|
|
%default total
|
2022-05-02 16:40:28 -04:00
|
|
|
%language ElabReflection
|
2021-07-20 16:05:19 -04:00
|
|
|
|
|
|
|
|
|
|
|
public export
|
2023-03-05 07:14:25 -05:00
|
|
|
data Universe = U Nat
|
2021-07-20 16:05:19 -04:00
|
|
|
%name Universe l
|
|
|
|
|
2023-03-02 13:52:32 -05:00
|
|
|
%runElab derive "Universe" [Eq, Ord, Show]
|
2021-07-20 16:05:19 -04:00
|
|
|
|
|
|
|
export
|
|
|
|
PrettyHL Universe where
|
|
|
|
prettyM (U l) = pure $ hl Free $ pretty l
|
2022-05-08 14:02:21 -04:00
|
|
|
|
2023-02-26 05:20:06 -05:00
|
|
|
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
|
|
|
|
|
2022-05-08 14:02:21 -04:00
|
|
|
export %inline
|
|
|
|
fromInteger : (x : Integer) -> (0 _ : So (x >= 0)) => Universe
|
|
|
|
fromInteger x = U $ fromInteger x
|