<html><body><p>Sure, but that's relying on the promise that you're passing it a valid BadFrog...&nbsp; 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 &lt;johnw@newartisans.com&gt;<br>Datum: 31. 8. 2012<br>Předmět: Re: [Haskell-cafe] Over general types are too easy to make.</p><blockquote>&gt;&gt;&gt;&gt;&gt;   &lt;timothyhobbs@seznam.cz&gt; writes:<br><br>&gt;&gt; data BadFoo =<br>&gt;&gt; BadBar{<br>&gt;&gt; badFoo::Int} |<br>&gt;&gt; BadFrog{<br>&gt;&gt; badFrog::String,<br>&gt;&gt; badChicken::Int}<br><br>&gt; This is fine, until we want to write a function that acts on Frogs but not<br>&gt; on Bars.  The best we can do is throw a runtime error when passed a Bar and<br>&gt; 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 -&gt; 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>