
If you change your type declarations to 'newtype' declarations, I
believe you would get the effect that you want, depending on what you
mean by 'equivalent'. In that case, Foo and Bar would essentially be
strings, but you could not use either of them in a place where the
other is expected, nor where a String is expected. See
http://haskell.org/haskellwiki/Newtype for more information. Hope this
helps!
On 10/10/07, Tom Davies
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?
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe