<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
</head>
<body dir="auto">
<div>(Caveat) In haskell specifically, i cant say, i rarely use it, and not in anger, im trying to pick it up again.</div>
<div><br>
</div>
<div>Set closure under an operation is common, and in maths is axiomatic to many theories eg group theory, in fact at some level its probably axiomatic to all maths eg model theory</div>
<div><br>
</div>
<div>Many useful operations are trivially closed eg arithmetic.</div>
<div><br>
</div>
<div>Operatosn that are closed to the domain of the operation can be generalised to N applications, eg because + on integer is closed i can apply it N times and derive * if it werent then 6*5 may be defined but 6*6 may not be! (Undefined throws a spanner in
 the works, but i'll ignore it)</div>
<div><br>
</div>
<div>I think in programming you rarely explicitly think about it, but you use it (arguably) everywhere</div>
<div><br>
</div>
<div>Closure under the typeclass instance type of kind *->* (i expect thats not the right way to say it) seems common in haskell, monoid, monad, num etc...... I wanted to see if there was a way to do it using type families over types of kind *, as in some ways
 this seems less onerous on the user of the class and more prescriptive.....ie fill in this type family def, write the operation definitoon and your done</div>
<div><br>
</div>
<div><br>
Excuse the spelling, sent from a phone with itty bitty keys, it like trying to sow a button on a shirt with a sausage.
<div><br>
</div>
</div>
<div><br>
On 7 Jan 2015, at 07:24, Dmin <<a href="mailto:dgomez1092@gmail.com">dgomez1092@gmail.com</a>> wrote:<br>
<br>
</div>
<blockquote type="cite">
<div>
<div dir="ltr">hi, i'm sorry to interject but this post caught my attention. 
<div><br>
</div>
<div>i understand how both classes help constrain the type ops</div>
<div><br>
</div>
<div>>> class Foo_ (S a) => Foo a where <br>
>> type S a <br>
>> op :: a -> (S a) </div>
<div><br>
</div>
<div>but what is really on my mind is for what purpose do you want to understand "closing" a type signature in a class. As a beginner myself I would venture to say this is common in haskell, no?  Is this a good analogy to the set-theory paradigm? Which I believe
 was the original question, right? </div>
<div><br>
</div>
<div><br>
<br>
On Tuesday, January 6, 2015 11:18:29 AM UTC-8, Nicholls, Mark wrote:
<blockquote class="gmail_quote" style="margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">
In fact i had tried somethjng very much like this but without the Foo_ and haskell wasnt happy with the cyclic definition
<br>
<br>
So maybe this is the answer! <br>
<br>
I'll let you know <br>
<br>
Excuse the spelling, sent from a phone with itty bitty keys, it like trying to sow a button on a shirt with a sausage.
<br>
<br>
<br>
> On 6 Jan 2015, at 19:14, Nicholls, Mark <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="TymJnodadEoJ" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">nichol...@vimn.com</a>> wrote:
<br>
> <br>
> Oooo <br>
> <br>
> I'll have a go with this tomorrow <br>
> <br>
> Thanks <br>
> <br>
> Excuse the spelling, sent from a phone with itty bitty keys, it like trying to sow a button on a shirt with a sausage.
<br>
> <br>
> <br>
>> On 6 Jan 2015, at 19:06, adam vogt <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="TymJnodadEoJ" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">vogt...@gmail.com</a>> wrote:
<br>
>> <br>
>> Hi, <br>
>> <br>
>> You can constrain the result type to be in the same class by writing <br>
>> something like: <br>
>> <br>
>> {-# LANGUAGE UndecidableInstances, FlexibleInstances #-} <br>
>> {-# LANGUAGE TypeFamilies, FlexibleContexts #-} <br>
>> <br>
>> class Foo_ a -- just to prevent a cycle in superclass constraints <br>
>> instance Foo a => Foo_ a <br>
>> <br>
>> class Foo_ (S a) => Foo a where <br>
>> type S a <br>
>> op :: a -> (S a) <br>
>> <br>
>> -- and an example where you get a compile error if "op x" has an instance, <br>
>> -- but "op (op x)" does not have an instance. <br>
>> instance Foo Int where <br>
>>   type S Int = Char <br>
>>   op = toEnum <br>
>> <br>
>> instance Foo Char where <br>
>>   type S Char = (Char,Char) <br>
>>   op x = (x,x) <br>
>> <br>
>> instance Foo (Char,Char) where <br>
>>   type S (Char,Char) = Int <br>
>>   op (x,y) = fromEnum x <br>
>> <br>
>> <br>
>>> On Tue, Jan 6, 2015 at 1:53 PM, Nicholls, Mark <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="TymJnodadEoJ" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">nichol...@vimn.com</a>> wrote:
<br>
>>> I will post the question again properly tomorrow but your example indeed is almost a good example, but is trivially closed
<br>
>>> <br>
>>> If the operation on monoid was <br>
>>> <br>
>>> [a]->[b]->[c] <br>
>>> <br>
>>> That is also closed; ie [c] is also a monoid.... And the typeclass declaration follows the idiom ive suggested
<br>
>>> <br>
>>> This only works for types of kind *->* <br>
>>> <br>
>>> If i wanted to do this over a type of kind * (ignoring the trivial a->a) <br>
>>> <br>
>>> Can i express this in a typeclass? <br>
>>> <br>
>>> Please ignore until i resubmit this question <br>
>>> <br>
>>> Ps i hate phones <br>
>>> <br>
>>> Excuse the spelling, sent from a phone with itty bitty keys, it like trying to sow a button on a shirt with a sausage.
<br>
>>> <br>
>>> <br>
>>>>> On 6 Jan 2015, at 18:10, Tom Ellis <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="TymJnodadEoJ" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">tom-lists-has...@<wbr>jaguarpaw.co.uk</a>>
 wrote: <br>
>>>>> <br>
>>>>> On Tue, Jan 06, 2015 at 05:43:47PM +0000, Nicholls, Mark wrote: <br>
>>>>> Its quite common in maths to have operations in a theory that are (set) <br>
>>>>> closed, i just want to translate that notion to a typeclass <br>
>>>> <br>
>>>> Do you really need a typeclass (or indeed any way) of doing this?  I suspect
<br>
>>>> it will not work.  If you consider the multiplication for the monoid of <br>
>>>> concatenation of lists <br>
>>>> <br>
>>>> (++) :: [a] -> [a] -> [a] <br>
>>>> <br>
>>>> you see that its type already implies that it is "closed". <br>
>>>> <br>
>>>> Tom <br>
>>>> ______________________________<wbr>_________________ <br>
>>>> Haskell-Cafe mailing list <br>
>>>> <a href="javascript:" target="_blank" gdf-obfuscated-mailto="TymJnodadEoJ" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">
Haskel...@haskell.org</a> <br>
>>>> <a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Fwww.haskell.org%2Fmailman%2Flistinfo%2Fhaskell-cafe\46sa\75D\46sntz\0751\46usg\75AFQjCNHiVycCM53czUVzPma4Fkb_wPqP2A';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Fwww.haskell.org%2Fmailman%2Flistinfo%2Fhaskell-cafe\46sa\75D\46sntz\0751\46usg\75AFQjCNHiVycCM53czUVzPma4Fkb_wPqP2A';return true;">
http://www.haskell.org/<wbr>mailman/listinfo/haskell-cafe</a> <br>
>>> CONFIDENTIALITY NOTICE <br>
>>> <br>
>>> This e-mail (and any attached files) is confidential and protected by copyright (and other intellectual property rights). If you are not the intended recipient please e-mail the sender and then delete the email and any attached files immediately. Any further
 use or dissemination is prohibited. <br>
>>> <br>
>>> While MTV Networks Europe has taken steps to ensure that this email and any attachments are virus free, it is your responsibility to ensure that this message and any attachments are virus free and do not affect your systems / data.
<br>
>>> <br>
>>> Communicating by email is not 100% secure and carries risks such as delay, data corruption, non-delivery, wrongful interception and unauthorised amendment. If you communicate with us by e-mail, you acknowledge and assume these risks, and you agree to take
 appropriate measures to minimise these risks when e-mailing us. <br>
>>> <br>
>>> MTV Networks International, MTV Networks UK & Ireland, Greenhouse, Nickelodeon Viacom Consumer Products, VBSi, Viacom Brand Solutions International, Be Viacom, Viacom International Media Networks and VIMN and Comedy Central are all trading names of MTV
 Networks Europe.  MTV Networks Europe is a partnership between MTV Networks Europe Inc. and Viacom Networks Europe Inc.  Address for service in Great Britain is 17-29 Hawley Crescent, London, NW1 8TT.
<br>
>>> <br>
>>> ______________________________<wbr>_________________ <br>
>>> Haskell-Cafe mailing list <br>
>>> <a href="javascript:" target="_blank" gdf-obfuscated-mailto="TymJnodadEoJ" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">
Haskel...@haskell.org</a> <br>
>>> <a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Fwww.haskell.org%2Fmailman%2Flistinfo%2Fhaskell-cafe\46sa\75D\46sntz\0751\46usg\75AFQjCNHiVycCM53czUVzPma4Fkb_wPqP2A';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Fwww.haskell.org%2Fmailman%2Flistinfo%2Fhaskell-cafe\46sa\75D\46sntz\0751\46usg\75AFQjCNHiVycCM53czUVzPma4Fkb_wPqP2A';return true;">
http://www.haskell.org/<wbr>mailman/listinfo/haskell-cafe</a> <br>
>> ______________________________<wbr>_________________ <br>
>> Haskell-Cafe mailing list <br>
>> <a href="javascript:" target="_blank" gdf-obfuscated-mailto="TymJnodadEoJ" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">
Haskel...@haskell.org</a> <br>
>> <a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Fwww.haskell.org%2Fmailman%2Flistinfo%2Fhaskell-cafe\46sa\75D\46sntz\0751\46usg\75AFQjCNHiVycCM53czUVzPma4Fkb_wPqP2A';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Fwww.haskell.org%2Fmailman%2Flistinfo%2Fhaskell-cafe\46sa\75D\46sntz\0751\46usg\75AFQjCNHiVycCM53czUVzPma4Fkb_wPqP2A';return true;">
http://www.haskell.org/<wbr>mailman/listinfo/haskell-cafe</a> <br>
CONFIDENTIALITY NOTICE <br>
<br>
This e-mail (and any attached files) is confidential and protected by copyright (and other intellectual property rights). If you are not the intended recipient please e-mail the sender and then delete the email and any attached files immediately. Any further
 use or dissemination is prohibited. <br>
<br>
While MTV Networks Europe has taken steps to ensure that this email and any attachments are virus free, it is your responsibility to ensure that this message and any attachments are virus free and do not affect your systems / data.
<br>
<br>
Communicating by email is not 100% secure and carries risks such as delay, data corruption, non-delivery, wrongful interception and unauthorised amendment. If you communicate with us by e-mail, you acknowledge and assume these risks, and you agree to take appropriate
 measures to minimise these risks when e-mailing us. <br>
<br>
MTV Networks International, MTV Networks UK & Ireland, Greenhouse, Nickelodeon Viacom Consumer Products, VBSi, Viacom Brand Solutions International, Be Viacom, Viacom International Media Networks and VIMN and Comedy Central are all trading names of MTV Networks
 Europe.  MTV Networks Europe is a partnership between MTV Networks Europe Inc. and Viacom Networks Europe Inc.  Address for service in Great Britain is 17-29 Hawley Crescent, London, NW1 8TT.
<br>
<br>
______________________________<wbr>_________________ <br>
Haskell-Cafe mailing list <br>
<a href="javascript:" target="_blank" gdf-obfuscated-mailto="TymJnodadEoJ" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">Haskel...@haskell.org</a>
<br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Fwww.haskell.org%2Fmailman%2Flistinfo%2Fhaskell-cafe\46sa\75D\46sntz\0751\46usg\75AFQjCNHiVycCM53czUVzPma4Fkb_wPqP2A';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Fwww.haskell.org%2Fmailman%2Flistinfo%2Fhaskell-cafe\46sa\75D\46sntz\0751\46usg\75AFQjCNHiVycCM53czUVzPma4Fkb_wPqP2A';return true;">http://www.haskell.org/<wbr>mailman/listinfo/haskell-cafe</a>
<br>
</blockquote>
</div>
</div>
</div>
</blockquote>
<P></P>
<P><br><br>CONFIDENTIALITY NOTICE<br><br>This e-mail (and any attached files) is confidential and protected by copyright (and other intellectual property rights). If you are not the intended recipient please e-mail the sender and then delete the email and any attached files immediately. Any further use or dissemination is prohibited.<br><br>While MTV Networks Europe has taken steps to ensure that this email and any attachments are virus free, it is your responsibility to ensure that this message and any attachments are virus free and do not affect your systems / data.<br><br>Communicating by email is not 100% secure and carries risks such as delay, data corruption, non-delivery, wrongful interception and unauthorised amendment. If you communicate with us by e-mail, you acknowledge and assume these risks, and you agree to take appropriate measures to minimise these risks when e-mailing us.<br><br>MTV Networks International, MTV Networks UK & Ireland, Greenhouse, Nickelodeon Viacom Consumer Products, VBSi, Viacom Brand Solutions International, Be Viacom, Viacom International Media Networks and VIMN and Comedy Central are all trading names of MTV Networks Europe.  MTV Networks Europe is a partnership between MTV Networks Europe Inc. and Viacom Networks Europe Inc.  Address for service in Great Britain is 17-29 Hawley Crescent, London, NW1 8TT.<br></P></body>
</html>