Skip to content

Instantly share code, notes, and snippets.

@maoe
Created August 26, 2011 10:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maoe/1173132 to your computer and use it in GitHub Desktop.
Save maoe/1173132 to your computer and use it in GitHub Desktop.
Scoped type variablesが必要になる例
{-# 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