Skip to content

Commit

Permalink
basic Singleton type
Browse files Browse the repository at this point in the history
  • Loading branch information
flupe committed Aug 14, 2024
1 parent 7753783 commit 16f3398
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions lib/Haskell/Extra/Singleton.agda
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
module Haskell.Extra.Singleton where

open import Haskell.Prelude

data Singleton (a : Set) : @0 a Set where
MkSingl : x Singleton a x

{-# COMPILE AGDA2HS Singleton unboxed #-}

pureSingl : {a : Set} (x : a) Singleton a x
pureSingl = MkSingl

{-# COMPILE AGDA2HS pureSingl inline #-}

fmapSingl
: {a b : Set} (f : a b) {@0 x : a}
Singleton a x
Singleton b (f x)
fmapSingl f (MkSingl x) = MkSingl (f x)

{-# COMPILE AGDA2HS fmapSingl inline #-}

0 comments on commit 16f3398

Please sign in to comment.