diff options
author | Josh Rahm <joshuarahm@gmail.com> | 2024-10-10 18:43:13 -0600 |
---|---|---|
committer | Josh Rahm <joshuarahm@gmail.com> | 2024-10-10 18:43:13 -0600 |
commit | cef70019330bb482a1418c026c57045ed731d51b (patch) | |
tree | f6c568e644df202b8b87e8967698a98776183912 /src/Language/Fiddle/Ast/Internal/SyntaxTree.hs | |
parent | c2f195a23bdb0d0dc876cc548d4c3157534082c6 (diff) | |
download | fiddle-cef70019330bb482a1418c026c57045ed731d51b.tar.gz fiddle-cef70019330bb482a1418c026c57045ed731d51b.tar.bz2 fiddle-cef70019330bb482a1418c026c57045ed731d51b.zip |
Change Witness to be a GADT.
This makes is much simpler to represent. Surprised I missed this
ability.
Diffstat (limited to 'src/Language/Fiddle/Ast/Internal/SyntaxTree.hs')
-rw-r--r-- | src/Language/Fiddle/Ast/Internal/SyntaxTree.hs | 20 |
1 files changed, 4 insertions, 16 deletions
diff --git a/src/Language/Fiddle/Ast/Internal/SyntaxTree.hs b/src/Language/Fiddle/Ast/Internal/SyntaxTree.hs index f627f15..9566ab5 100644 --- a/src/Language/Fiddle/Ast/Internal/SyntaxTree.hs +++ b/src/Language/Fiddle/Ast/Internal/SyntaxTree.hs @@ -17,7 +17,6 @@ module Language.Fiddle.Ast.Internal.SyntaxTree BitsOffset, -- Witness Types Witness (..), - WitnessType, -- AST Types Name (..), Directive (..), @@ -60,7 +59,6 @@ import Data.List.NonEmpty hiding (map) import Data.Text (Text) import Data.Type.Bool import Data.Typeable -import Data.Void (Void) import Data.Word (Word32) import GHC.Generics import Language.Fiddle.Ast.Internal.Instances @@ -107,22 +105,12 @@ type family NumberType (a :: Stage) :: Type where type family ImportInterface (stage :: Stage) :: Type where ImportInterface s = If (s < ImportsResolved) () UnitInterface --- | A way to disable or enable a subtree type based on a type-level boolean. +-- | A type which is only constructible if the type-level condition 's' holds. -- --- This is used over GADT's specific parameterization to allow for deriving --- generics and reduce boilerplate. --- --- This is a wrapper type to allow defining instances. +-- This type is used as a way to enable/disable parts of the syntax tree based +-- on type level booleans (typically incorporating the compilation 'stage') data Witness (s :: Bool) where - Witness :: (WitnessType s) -> Witness s - --- | If the type level expression is true, the witness type is the Unit type, if --- it is false, the witness type is Void, thus making whatever it touches --- uninhabitable. This is how parts of the AST is enabled or disabled during --- compilation. -type family WitnessType (s :: Bool) where - WitnessType True = () - WitnessType False = Void + Witness :: Witness True -- A Name is multiple identifiers separated by dots. It's the way of namespaces -- to different packages. |