[Haskell-cafe] Type Synonyms

Tom Davies tgdavies at gmail.com
Wed Oct 10 23:06:14 EDT 2007


Newbie question:

I was wondering the other day if type synonyms might be more useful 
if they were more restricted, that is, with the definitions:

type Foo = String
type Bar = String

foo :: Foo
foo = "a foo"

bar :: Bar
bar = "a bar"

x :: Foo -> ...
x f b = ...only valid for Foo Strings...

both 'x foo' and 'x bar' type check correctly.

Wouldn't it be useful if Foo and Bar were both equivalent to String,
but Foo and Bar were not equivalent themselves? 

For instance, 
if you are using Strings as properties of something and want 
to associate the type of the property with its value, without 
wrapping the String. 

Would this break a transitivity property of 
the type system?

Am I just suffering from laziness?





More information about the Haskell-Cafe mailing list