Created
March 2, 2019 22:13
-
-
Save monadplus/9e590a39b423139244fcdc81ee743e1f to your computer and use it in GitHub Desktop.
Existentially qualified types in Scala
This file contains hidden or 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
/* | |
data ShowBox = forall s. Show s => SB s | |
heteroList :: [ShowBox] | |
heteroList = [SB (), SB 5, SB True] | |
----- | |
instance Show ShowBox where | |
show (SB s) = show s | |
f :: [ShowBox] -> IO () | |
f xs = mapM_ print xs | |
main = f heteroList | |
*/ | |
def show(as : List[F[_]] forSome { type F[_] <: Show[_]}): IO[String] = | |
as.traverse(a => IO.pure(a.show(_))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment