Last active
June 25, 2022 22:37
-
-
Save ramirez7/5df3e61fc05056571ce0fdb694aa22d2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| {-# LANGUAGE KindSignatures #-} | |
| {-# LANGUAGE DataKinds #-} | |
| {-# LANGUAGE TypeFamilies #-} | |
| {-# LANGUAGE LambdaCase #-} | |
| {-# LANGUAGE RankNTypes #-} | |
| {-# LANGUAGE TypeFamilyDependencies #-} | |
| {- | |
| Here are the GHC/singletons versions I used to run this: | |
| $ nix-shell -p haskell.compiler.ghc921 --command 'cabal repl -b "singletons == 3.0.1" -b "singletons-base == 3.1"' | |
| -} | |
| module SingletonBool where | |
| import Data.Singletons | |
| import Prelude.Singletons | |
| import Data.Kind | |
| -- You might as well mark this as injective since it is: | |
| type family F (b :: Bool) = (r :: Type) | r -> b where | |
| F True = Int | |
| F False = Char | |
| f1 :: forall (x :: Bool). (Sing x -> F x) -> Sing x -> F x | |
| f1 = ($) | |
| f2 :: Sing x -> F x | |
| f2 = \case | |
| STrue -> 2 | |
| SFalse -> 'b' | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment