Created
August 26, 2011 10:11
-
-
Save maoe/1173132 to your computer and use it in GitHub Desktop.
Scoped type variablesが必要になる例
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 ScopedTypeVariables #-} | |
module ScopedTypeVars where | |
bounds :: forall a. (Show a, Bounded a) => a -> (String, String) | |
bounds x = (minBoundS, maxBoundS) | |
where | |
minBoundS = show (minBound :: a) | |
maxBoundS = show (maxBound :: a) | |
bounds' :: (Show a, Bounded a) => a -> (String, String) | |
bounds' x = (minBoundS, maxBoundS) | |
where | |
minBoundS = show (minBound `asTypeOf` x) | |
maxBoundS = show (maxBound `asTypeOf` x) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment