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 CPP #-} | |
{-# LANGUAGE ScopedTypeVariables #-} | |
{-# LANGUAGE FlexibleInstances, FlexibleContexts #-} | |
{-# LANGUAGE DataKinds, GADTs, KindSignatures, TypeOperators, UndecidableInstances #-} | |
#if __GLASGOW_HASKELL__ < 708 | |
#error "requires GHC 7.10 or newer" | |
#endif | |
module Main (main) where |
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
/// This type is only every inhabited when S is nominally equivalent to T | |
#[derive(Debug)] | |
pub struct Is<S, T>(::std::marker::PhantomData<(*const S, *const T)>); | |
// Construct a proof of the fact that a type is nominally equivalent | |
// to itself. | |
pub fn is<T>() -> Is<T, T> { Is(::std::marker::PhantomData) } | |
// std::mem::transmute does not accept unsubstituted type parameters | |
// manual transmute as suggested by manual |
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
/// This type is only every inhabited when S is nominally equivalent to T | |
pub type Is <S, T> = Is_ <S, T>; | |
priv struct Is_ <S, T>; | |
// Construct a proof of the fact that a type is nominally equivalent | |
// to itself. | |
pub fn Is <T> () -> Is <T, T> { Is_ } | |
pub impl <S, T> Is_ <S, T> { |