<html><body><p>Sure, but that's relying on the promise that you're passing it a valid BadFrog... Consider then:</p><p><br></p><p>deBadFrog $ BadFrogType (BadBar { badFoo = 1})</p><p><br></p><p>---------- Původní zpráva ----------<br>Od: John Wiegley <johnw@newartisans.com><br>Datum: 31. 8. 2012<br>Předmět: Re: [Haskell-cafe] Over general types are too easy to make.</p><blockquote>>>>>> <timothyhobbs@seznam.cz> writes:<br><br>>> data BadFoo =<br>>> BadBar{<br>>> badFoo::Int} |<br>>> BadFrog{<br>>> badFrog::String,<br>>> badChicken::Int}<br><br>> This is fine, until we want to write a function that acts on Frogs but not<br>> on Bars. The best we can do is throw a runtime error when passed a Bar and<br>> not a Foo:<br><br>You can use wrapper types to solve this:<br><br> data BadBarType = BadBarType BadFoo<br> data BadFrogType = BadFrogType BadFoo<br><br>Now you can have:<br><br> deBadFrog :: BadFrogType -> String<br><br>And call it as:<br><br> deBadFrog $ BadFrogType (BadFrog { badFrog = "Hey", badChicken = 1})<br><br>Needless to say, you will have to create helper functions for creating Bars<br>and Frogs, and not allow your BadBar or BadFrog value constructors to be<br>visible outside your module.<br><br>John<br><br>_______________________________________________<br>Haskell-Cafe mailing list<br>Haskell-Cafe@haskell.org<br><a href="http://www.haskell.org/mailman/listinfo/haskell-cafe">http://www.haskell.org/mailman/listinfo/haskell-cafe</a></blockquote></body></html>