Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {-# LANGUAGE ScopedTypeVariables #-}
- module ProxyExample where
- ------------------------
- import Data.Proxy
- import Prelude
- -------------------------
- -- This will not compile:
- -- showread :: String -> String
- -- showread = show . read
- -- ScopedTypeVariables: otherwise refering a is not possible
- --
- -- showread (Proxy :: Proxy Int) "3"
- -- "3"
- -- showread (Proxy :: Proxy Bool) "'fail'"
- -- **exception**
- showread :: forall a. (Show a, Read a) => Proxy a -> String -> String
- showread _ = (show :: a -> String) . read
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement