<div dir="ltr"><div>As the title says.<br></div><div><br>Motivation:<br><div style="margin-left:40px">in a mutable code I want to keep some parameters strictly immutable, i.e. not sharing s with the whole mutable type<br></div></div><div><br>I think this is best illustrated by 2 examples:<br><div style="margin-left:40px">1. abstract example:<br></div><div style="margin-left:80px">imagine I have a type<br></div><div style="margin-left:80px"><div style="margin-left:40px">X a b c<br></div></div><div style="margin-left:80px">and another type<br></div><div style="margin-left:80px"><div style="margin-left:40px">Y a b<br></div></div><div style="margin-left:80px">and I want to prevent any case where the first parameter of X "a" is shared with it's third parameter "c" i.e. X a b (Y a a), X a b (Y a b), X a b (Y b a), X a b (Y a d) etc., any nestings in Y referencing a etc.<br></div><div style="margin-left:40px"><div style="margin-left:40px">but allow<br></div></div><div style="margin-left:40px"><div style="margin-left:40px"><div style="margin-left:40px">X a b (Y b b), X a b (Y b c)<br>and any other combination not ruled out above<br></div></div></div><div style="margin-left:40px">2. concrete example:<br></div><div style="margin-left:40px"><div style="margin-left:40px">imagine I have a type:<br></div></div><div style="margin-left:80px"><div style="margin-left:40px">Item s element key<br></div></div><div style="margin-left:40px"><div style="margin-left:40px">where s is used in the same way as in STRef s a, i.e. it cannot leak outside of a certain context, but I want the key to be immutable i.e. independent of s under any circumstences, so I can't write a type like:<br></div></div><div style="margin-left:40px"><div style="margin-left:40px"><div style="margin-left:40px">Item s element (STRef s refType)<br></div></div></div><div style="margin-left:40px"><div style="margin-left:40px">this is equivalent to disallowing X a b (Y a d) in 1.<br></div></div><div style="margin-left:40px"><br></div>Is there any way to write a restriction like this in Haskell?<br><br>--<br></div><div>  Timo<br></div></div>