Skip to content

Instantly share code, notes, and snippets.

@MonoidMusician
Last active January 10, 2018 01:57
Show Gist options
  • Save MonoidMusician/6595ab108f958bd287c879103fc36f57 to your computer and use it in GitHub Desktop.
Save MonoidMusician/6595ab108f958bd287c879103fc36f57 to your computer and use it in GitHub Desktop.
Impredicativity woes
module Main where
import Prelude
import Data.Maybe (Maybe(..), fromMaybe)
import Unsafe.Coerce (unsafeCoerce)
type Id = forall a. a -> a
newtype ID = ID Id
mkID :: Id -> ID
mkID = ID
runID :: ID -> Id
runID (ID id') = id'
aThing' :: Maybe ID
aThing' = Nothing
runAThing' :: Id
runAThing' = runID (fromMaybe (mkID id) aThing')
choose :: forall f b. Functor f => f Id -> f (b -> b)
choose faa = faa <#> \a -> a
aThing :: Maybe (forall a. a -> a)
aThing = (Just :: Id -> Maybe Id) id
runAThing :: forall z. z -> z
runAThing = (fromMaybeId :: Maybe (z -> z) -> (z -> z)) (choose aThing :: Maybe (z -> z)) where
fromMaybeId :: Maybe (z -> z) -> z -> z
fromMaybeId = (fromMaybe :: (z -> z) -> Maybe (z -> z) -> (z -> z)) (id :: z -> z)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment