<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div>Hello!</div><div><br></div><div>Consider the following code:</div><div><br></div><div><div>module Units where</div><div><br></div><div>data Units a = U Double deriving Eq</div><div><br></div><div>units :: Double -> a -> Units a</div><div>units value _ = U value</div><div><br></div><div>data Meters</div><div>data Yards</div><div><br></div><div>meters = undefined :: Meters</div><div>yards = undefined :: Yards</div><div><br></div><div>instance Show Meters where</div><div>  show _ = "meters"</div><div><br></div><div>instance Show Yards where</div><div>  show _ = "yards"</div><div><br></div><div>extractA :: Units a -> a</div><div>extractA = undefined</div><div><br></div><div>instance Show a => Show (Units a) where</div><div>  show u@(U value) = show value ++ " " ++ show $ extractA u</div><div><br></div><div>main = (print $ units 5 yards) >> (print $ units 5 meters)</div></div><div><br></div><div>Is it possible to use something instead extractA function here? For example, substitute "extractA u” with “undefined :: a”?</div><div>GHC disallows it, so is there a way to explain that I only need a token with type a?</div><div><br></div><div>Also, with highlighting on lpaste: <a href="http://lpaste.net/138219">http://lpaste.net/138219</a>.</div><div><br></div><div>
<div style="color: rgb(0, 0, 0); letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div style="color: rgb(0, 0, 0); letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div>With regards,</div><div>Nikita Kartashov</div><div><br></div></div><br class="Apple-interchange-newline"></div><br class="Apple-interchange-newline"><br class="Apple-interchange-newline">
</div>

<br></body></html>