Created
April 7, 2018 22:58
-
-
Save shlevy/965955a5b7873e269ac845615f3e3d77 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 RankNTypes #-} | |
{-# LANGUAGE TypeApplications #-} | |
module Test where | |
newtype Value a = Value a | |
class MaybeHasValue x where | |
maybeValue :: Maybe (Value x) | |
data Void | |
instance MaybeHasValue Void where | |
maybeValue = Nothing | |
instance MaybeHasValue () where | |
maybeValue = Just (Value ()) | |
foo :: forall a . MaybeHasValue a => Maybe (Value a) | |
foo = maybeValue | |
bar :: (forall a . MaybeHasValue a => Value a) -> Void | |
bar f = case f of | |
Value x -> x | |
baz :: (forall a . MaybeHasValue a => Maybe (Value a)) -> Maybe Void | |
baz f = case f @() of | |
Just v -> Just $ bar v | |
Nothing -> Nothing |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment