Skip to content

Commit

Permalink
split variants file into defs and default langs
Browse files Browse the repository at this point in the history
  • Loading branch information
pmbittner committed Nov 20, 2023
1 parent 3b58684 commit 0acf064
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 32 deletions.
2 changes: 1 addition & 1 deletion src/Framework/V2/Compiler.agda
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Framework.V2.Compiler where

open import Framework.V2.Variants
open import Framework.V2.Variant
open import Framework.V2.Definitions
open import Relation.Binary.PropositionalEquality as Eq using (_≗_)
open import Data.Product using (_×_)
Expand Down
2 changes: 1 addition & 1 deletion src/Framework/V2/Constructs/Artifact.agda
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ open import Level using (_⊔_)
open import Function using (id; _$_)
open import Relation.Binary.PropositionalEquality as Eq using (_≡_; refl)

open import Framework.V2.Variants
open import Framework.V2.Variant
open import Framework.V2.Definitions hiding (Semantics)
open import Framework.V2.Compiler as Comp using (LanguageCompiler; ConfigTranslation; ConstructFunctor; Stable)
open LanguageCompiler
Expand Down
2 changes: 1 addition & 1 deletion src/Framework/V2/Constructs/Choices.agda
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ module Choiceₙ where
show show-q show-a (D ⟨ es ⟩) = show-q D <+> "⟨" <+> (intersperse " , " (toList (map-list⁺ show-a es))) <+> "⟩"

-- Show how choices can be used as constructors in variability languages.
open import Framework.V2.Variants
open import Framework.V2.Variant
open import Framework.V2.Definitions as Defs hiding (Semantics)
open import Data.Product using (_,_; proj₁; proj₂)
open import Function using (id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ open import Relation.Binary.PropositionalEquality as Eq using (_≗_; refl)

import Data.IndexedSet

open import Framework.V2.Variants
open import Framework.V2.Variant
open import Framework.V2.Compiler using (LanguageCompiler; Stable)

import Framework.V2.Translation.Construct.2Choice-to-NChoice as 2→N
Expand Down
3 changes: 2 additions & 1 deletion src/Framework/V2/Translation/Lang/2ADT-to-NADT.agda
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ import Data.IndexedSet
import Framework.V2.Constructs.Choices
open Framework.V2.Constructs.Choices.Choiceₙ renaming (map to mapₙ)

open import Framework.V2.Variants using (VariantSetoid; GrulerVariant)
open import Framework.V2.Variant using (VariantSetoid)
open import Framework.V2.Variants using (GrulerVariant)
open import Framework.V2.Lang.2ADT
open import Framework.V2.Lang.NADT

Expand Down
2 changes: 1 addition & 1 deletion src/Framework/V2/V1Compat.agda
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ open import Relation.Binary.PropositionalEquality as Eq using (_≡_; _≗_; ref
import Data.IndexedSet

open import Framework.V2.Definitions
open import Framework.V2.Variants
open import Framework.V2.Variant

private
variable
Expand Down
32 changes: 32 additions & 0 deletions src/Framework/V2/Variant.agda
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
open import Framework.V2.Definitions using (𝕍; 𝔸)
module Framework.V2.Variant (V : 𝕍) (A : 𝔸) where

open import Data.Fin using (Fin)
open import Data.List using (List)
open import Data.Nat using (ℕ; suc)

open import Level using (0ℓ)
open import Relation.Binary using (Setoid)
import Relation.Binary.PropositionalEquality as Eq

import Data.IndexedSet

VariantSetoid : Setoid 0ℓ 0ℓ
VariantSetoid = Eq.setoid (V A)

module IVSet = Data.IndexedSet VariantSetoid

IndexedVMap : Set Set
IndexedVMap I = IndexedSet I
where open IVSet using (IndexedSet)

{-|
Variant maps constitute the semantic domain of variability languages.
While we defined variant maps to be indexed sets with an arbitrary finite and non-empty index set, we directly reflect these properties
via Fin (suc n) here for convenience.
-}
VMap : Set
VMap n = IndexedVMap (Fin (suc n))

forget-first : {n} VMap (suc n) VMap n
forget-first set i = set (Data.Fin.suc i)
26 changes: 0 additions & 26 deletions src/Framework/V2/Variants.agda
Original file line number Diff line number Diff line change
@@ -1,38 +1,12 @@
module Framework.V2.Variants where

open import Data.Fin using (Fin)
open import Data.List using (List)
open import Data.Nat using (ℕ; suc)

open import Level using (0ℓ)
open import Relation.Binary using (Setoid)
import Relation.Binary.PropositionalEquality as Eq

open import Framework.V2.Definitions using (𝕍; 𝔸)
open import Framework.V2.Constructs.Plain.Artifact using (Artifact)

import Data.IndexedSet

data GrulerVariant : 𝕍 where
asset : {A : 𝔸} (a : A) GrulerVariant A
_∥_ : {A : 𝔸} (l : GrulerVariant A) (r : GrulerVariant A) GrulerVariant A

data Rose : 𝕍 where
artifact : {A : 𝔸} Artifact A (Rose A) Rose A

VariantSetoid : 𝕍 𝔸 Setoid 0ℓ 0ℓ
VariantSetoid V A = Eq.setoid (V A)

module IVSet (V : 𝕍) (A : 𝔸) = Data.IndexedSet (VariantSetoid V A)

IndexedVMap : 𝕍 𝔸 Set Set
IndexedVMap V A I = IndexedSet I
where open IVSet V A using (IndexedSet)

{-|
Variant maps constitute the semantic domain of variability languages.
While we defined variant maps to be indexed sets with an arbitrary finite and non-empty index set, we directly reflect these properties
via Fin (suc n) here for convenience.
-}
VMap : 𝕍 𝔸 Set
VMap V A n = IndexedVMap V A (Fin (suc n))

0 comments on commit 0acf064

Please sign in to comment.