Skip to content

Instantly share code, notes, and snippets.

@ndmitchell
Created August 15, 2018 21:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ndmitchell/f2f2437fc3d8687cc028f51f526b3b81 to your computer and use it in GitHub Desktop.
Save ndmitchell/f2f2437fc3d8687cc028f51f526b3b81 to your computer and use it in GitHub Desktop.
Compile with no ghc libraries installed
-- Compile with:
-- ghc -hide-all-packages -fforce-recomp GHC/Types.hs -this-unit-id=ghc-prim
{-# LANGUAGE NoImplicitPrelude, MagicHash #-}
module GHC.Types where
import GHC.Prim
default ()
data Module = Module
TrName -- Package name
TrName -- Module name
data TrName
= TrNameS Addr# -- Static
| TrNameD [Char] -- Dynamic
data Char = C# Char#
data Int = I# Int#
data [] a = [] | a : [a]
-- | A de Bruijn index for a binder within a 'KindRep'.
type KindBndr = Int
-- | The representation produced by GHC for conjuring up the kind of a
-- 'TypeRep'. See Note [Representing TyCon kinds: KindRep] in TcTypeable.
data KindRep = KindRepTyConApp TyCon [KindRep]
| KindRepVar !KindBndr
| KindRepApp KindRep KindRep
| KindRepFun KindRep KindRep
| KindRepTYPE !RuntimeRep
| KindRepTypeLitS TypeLitSort Addr#
| KindRepTypeLitD TypeLitSort [Char]
data TypeLitSort = TypeLitSymbol
| TypeLitNat
-- Show instance for TyCon found in GHC.Show
data TyCon = TyCon Word# Word# -- Fingerprint
Module -- Module in which this is defined
TrName -- Type constructor name
Int# -- How many kind variables do we accept?
KindRep -- A representation of the type's kind
data RuntimeRep = VecRep VecCount VecElem -- ^ a SIMD vector type
| TupleRep [RuntimeRep] -- ^ An unboxed tuple of the given reps
| SumRep [RuntimeRep] -- ^ An unboxed sum of the given reps
| LiftedRep -- ^ lifted; represented by a pointer
| UnliftedRep -- ^ unlifted; represented by a pointer
| IntRep -- ^ signed, word-sized value
| WordRep -- ^ unsigned, word-sized value
| Int64Rep -- ^ signed, 64-bit value (on 32-bit only)
| Word64Rep -- ^ unsigned, 64-bit value (on 32-bit only)
| AddrRep -- ^ A pointer, but /not/ to a Haskell value
| FloatRep -- ^ a 32-bit floating point number
| DoubleRep -- ^ a 64-bit floating point number
data VecCount = Vec2
| Vec4
| Vec8
| Vec16
| Vec32
| Vec64
-- Enum, Bounded instances in GHC.Enum
-- | Element of a SIMD vector type
data VecElem = Int8ElemRep
| Int16ElemRep
| Int32ElemRep
| Int64ElemRep
| Word8ElemRep
| Word16ElemRep
| Word32ElemRep
| Word64ElemRep
| FloatElemRep
| DoubleElemRep
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment