Last active
August 29, 2015 14:06
-
-
Save gallais/892e400524bef4405fde to your computer and use it in GitHub Desktop.
This file contains 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 DeriveDataTypeable #-} | |
module LEM where | |
import Control.Exception | |
import Data.Typeable | |
import System.IO.Unsafe | |
data Void | |
absurd :: Void -> a | |
absurd a = a `seq` error "Value of type void." | |
type Lem a = Either a (a -> Void) | |
newtype Wrap a = Wrap { unwrap :: a } deriving (Typeable, Show) | |
instance (Show a, Typeable a) => Exception (Wrap a) | |
cut :: (Show a, Typeable a) => (Lem a -> c) -> c | |
cut f = unsafePerformIO $ catch lie recover | |
where lie = return $! f $ Right $ throw . Wrap | |
recover = return . f . Left . unwrap |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment