Skip to content

Commit

Permalink
Add ifDec function for branching on a Dec that compiles to if
Browse files Browse the repository at this point in the history
  • Loading branch information
jespercockx committed Jan 24, 2024
1 parent a618fac commit 48aacea
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/Haskell/Extra/Dec.agda
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,7 @@ mapDec : @0 (a → b)
mapDec f g (True ⟨ x ⟩) = True ⟨ f x ⟩
mapDec f g (False ⟨ h ⟩) = False ⟨ h ∘ g ⟩
{-# COMPILE AGDA2HS mapDec transparent #-}

ifDec : Dec a (@0 {{a}} b) (@0 {{a ⊥}} b) b
ifDec (b ⟨ p ⟩) x y = if b then (λ where {{refl}} x {{p}}) else (λ where {{refl}} y {{p}})
{-# COMPILE AGDA2HS ifDec inline #-}

0 comments on commit 48aacea

Please sign in to comment.