Created
September 7, 2021 20:28
-
-
Save evanrelf/58c5c15e5a50130a4f81c90193b1cae3 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
module Main where | |
import Prelude hiding (show) | |
import Prelude as Prelude | |
import Data.Foldable (fold) | |
import Effect (Effect) | |
import TryPureScript (p, text, render) | |
newtype Identity a = Identity a | |
runIdentity :: forall a. Identity a -> a | |
runIdentity (Identity x) = x | |
-- DOES NOT WORK :-( | |
-- myWrappedShow1 :: Identity (forall a. Show a => a -> String) | |
-- myWrappedShow1 = Identity Prelude.show | |
-- WORKS :-) | |
newtype SomeShow = SomeShow (forall a. Show a => a -> String) | |
myWrappedShow2 :: Identity SomeShow | |
myWrappedShow2 = Identity (SomeShow Prelude.show) | |
main :: Effect Unit | |
main = | |
render $ fold | |
[ p $ text $ myShow 42 | |
, p $ text $ myShow true | |
] | |
where | |
myShow :: forall a. Show a => a -> String | |
-- DOES NOT WORK :-( | |
-- myShow = myWrappedShow1 # runIdentity | |
-- WORKS :-) | |
myShow = myWrappedShow2 # runIdentity >>> (\(SomeShow f) -> f) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment