lude

Haskell prelude alternative
git clone git://git.rr3.xyz/lude | git clone gits://git.rr3.xyz/lude
Log | Files | Refs | README | LICENSE

Repr.hs (1937B)


      1 module Lude.Haskell.Repr (
      2     EvalOrder,
      3     Lazy,
      4     Eager,
      5     Unit,
      6     Tuple,
      7     Sum,
      8     Box,
      9     BoxL,
     10     BoxE,
     11     Addr,
     12     Nat,
     13     Nat8,
     14     Nat16,
     15     Nat32,
     16     Nat64,
     17     Int,
     18     Int8,
     19     Int16,
     20     Int32,
     21     Int64,
     22     Flt32,
     23     Flt64,
     24 ) where
     25 
     26 import GHC.Exts qualified as GHC
     27 
     28 import Lude.Haskell.Core
     29 import Lude.Haskell.List
     30 
     31 -- TODO: SIMD
     32 
     33 -- TODO: Export Repr patterns? (Non-exhaustive until we add SIMD support.)
     34 
     35 -- TODO: Rename "Tuple" and "Sum". I don't like how asymmetric these names are.
     36 
     37 -- TODO: Rename Int and Nat. The name should clearly indicate that the bit size
     38 -- is implementation-dependent.
     39 
     40 --------------------------------------------------------------------------------
     41 
     42 type EvalOrder :: Kind
     43 type EvalOrder = GHC.Levity
     44 
     45 type Lazy :: EvalOrder
     46 type Lazy = GHC.Lifted
     47 
     48 type Eager :: EvalOrder
     49 type Eager = GHC.Unlifted
     50 
     51 --------------------------------------------------------------------------------
     52 
     53 -- NOTE: There is no Void repr, because there are no values of type Void to
     54 -- represent!
     55 
     56 type Unit :: Repr
     57 type Unit = GHC.TupleRep []
     58 
     59 type Tuple :: List Repr -> Repr
     60 type Tuple = GHC.TupleRep
     61 
     62 type Sum :: List Repr -> Repr
     63 type Sum = GHC.SumRep
     64 
     65 type Box :: EvalOrder -> Repr
     66 type Box = GHC.BoxedRep
     67 
     68 type BoxL :: Repr
     69 type BoxL = GHC.BoxedRep Lazy
     70 
     71 type BoxE :: Repr
     72 type BoxE = GHC.BoxedRep Eager
     73 
     74 type Addr :: Repr
     75 type Addr = GHC.AddrRep
     76 
     77 type Nat :: Repr
     78 type Nat = GHC.WordRep
     79 
     80 type Nat8 :: Repr
     81 type Nat8 = GHC.Word8Rep
     82 
     83 type Nat16 :: Repr
     84 type Nat16 = GHC.Word16Rep
     85 
     86 type Nat32 :: Repr
     87 type Nat32 = GHC.Word32Rep
     88 
     89 type Nat64 :: Repr
     90 type Nat64 = GHC.Word64Rep
     91 
     92 type Int :: Repr
     93 type Int = GHC.IntRep
     94 
     95 type Int8 :: Repr
     96 type Int8 = GHC.Int8Rep
     97 
     98 type Int16 :: Repr
     99 type Int16 = GHC.Int16Rep
    100 
    101 type Int32 :: Repr
    102 type Int32 = GHC.Int32Rep
    103 
    104 type Int64 :: Repr
    105 type Int64 = GHC.Int64Rep
    106 
    107 type Flt32 :: Repr
    108 type Flt32 = GHC.FloatRep
    109 
    110 type Flt64 :: Repr
    111 type Flt64 = GHC.DoubleRep