<div dir="ltr"><font color="#003333"><font size="2"><font face="trebuchet ms,sans-serif"><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: arial; ">Brent Yorgey wrote</span></font></font></font><div><font color="#003333"><font size="2"><font face="trebuchet ms,sans-serif"><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: arial; ">> Someone did respond to your question, with a link to the data-accessor<br>
> package on Hackage (you could also take a look at fclabels or<br>> lenses). Do those help address your issue?</span></font></font></font></div><div><font color="#003333"><font size="2"><font face="trebuchet ms,sans-serif"><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: arial; "><br>
</span></font></font></font></div><div><font class="Apple-style-span" face="'trebuchet ms', sans-serif"><font class="Apple-style-span" color="#003333">It's not accessing the data that concerns me, it's updating other elements.</font></font></div>
<div><font class="Apple-style-span" face="'trebuchet ms', sans-serif"><font class="Apple-style-span" color="#003333"><br></font></font></div><div><font class="Apple-style-span" face="'trebuchet ms', sans-serif"><font class="Apple-style-span" color="#003333">Imagine a system that tracks student registration.</font></font></div>
<div><font class="Apple-style-span" face="'trebuchet ms', sans-serif"><font class="Apple-style-span" color="#003333"><br></font></font></div><div><font class="Apple-style-span" face="'trebuchet ms', sans-serif"><font class="Apple-style-span" color="#003333">data Student = Student { sName :: String</font></font></div>
<div><span class="Apple-style-span" style="font-family: 'trebuchet ms', sans-serif; color: rgb(0, 51, 51); "> {- , ... Other stuff -}</span></div><div><font class="Apple-style-span" face="'trebuchet ms', sans-serif"><font class="Apple-style-span" color="#003333"> , coursesTaking :: [Course]</font></font></div>
<div><font class="Apple-style-span" face="'trebuchet ms', sans-serif"><font class="Apple-style-span" color="#003333"> }</font></font></div><div><font class="Apple-style-span" face="'trebuchet ms', sans-serif"><font class="Apple-style-span" color="#003333"><br>
</font></font><div dir="ltr"><font><font face="'trebuchet ms', sans-serif"><i><font color="#003333"><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: arial; font-style: normal; "><div><font class="Apple-style-span" face="'trebuchet ms', sans-serif"><font class="Apple-style-span" color="#003333"><div>
data Rank = Assist | Assoc | Full</div><div><br></div>data Instructor = Student { iName :: String</font></font></div><div><font class="Apple-style-span" face="'trebuchet ms', sans-serif"><font class="Apple-style-span" color="#003333"> , rank :: Rank -- defined, say, as data Rank = Assist | Assoc | Full</font></font></div>
<div><font class="Apple-style-span" face="'trebuchet ms', sans-serif"><font class="Apple-style-span" color="#003333"> </font></font><span class="Apple-style-span" style="font-family: 'trebuchet ms', sans-serif; "><i><font color="#003333"><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: arial; font-style: normal; "><div style="display: inline !important; ">
<font class="Apple-style-span" face="'trebuchet ms', sans-serif"><font class="Apple-style-span" color="#003333">{- , ... Other stuff -}</font></font></div></span></font></i></span></div><div><font class="Apple-style-span" face="'trebuchet ms', sans-serif"><font class="Apple-style-span" color="#003333"> , coursesTeaching :: [Course]</font></font></div>
<div><font class="Apple-style-span" face="'trebuchet ms', sans-serif"><font class="Apple-style-span" color="#003333"> }</font></font></div><div><font class="Apple-style-span" face="'trebuchet ms', sans-serif"><font class="Apple-style-span" color="#003333"><br>
</font></font></div><div><font class="Apple-style-span" face="'trebuchet ms', sans-serif"><font class="Apple-style-span" color="#003333">data Course = Course { cName :: String</font></font></div><div><font class="Apple-style-span" face="'trebuchet ms', sans-serif"><font class="Apple-style-span" color="#003333"> , units :: Int</font></font></div>
<div><font class="Apple-style-span" face="'trebuchet ms', sans-serif"><font class="Apple-style-span" color="#003333"> </font></font><span class="Apple-style-span" style="font-family: 'trebuchet ms', sans-serif; "><i><font color="#003333"><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: arial; font-style: normal; "><div style="display: inline !important; ">
<font class="Apple-style-span" face="'trebuchet ms', sans-serif"><font class="Apple-style-span" color="#003333"> {- , ... Other stuff -}</font></font></div></span></font></i></span></div>
<div><font class="Apple-style-span" face="'trebuchet ms', sans-serif"><font class="Apple-style-span" color="#003333"> , instructor :: Instructor</font></font></div><div><font class="Apple-style-span" face="'trebuchet ms', sans-serif"><font class="Apple-style-span" color="#003333"> , enrolledStudents :: [Student]</font></font></div>
<div><font class="Apple-style-span" face="'trebuchet ms', sans-serif"><font class="Apple-style-span" color="#003333"> }</font></font></div><div><font class="Apple-style-span" face="'trebuchet ms', sans-serif"><font class="Apple-style-span" color="#003333"><br>
</font></font></div><div><span class="Apple-style-span" style="font-family: 'trebuchet ms', sans-serif; "><i><font color="#003333"><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: arial; font-style: normal; "><div style="display: inline !important; ">
<font class="Apple-style-span" face="'trebuchet ms', sans-serif"><font class="Apple-style-span" color="#003333">Suppose I want a function that drops a student from a class.</font></font></div></span></font></i></span></div>
<div><font class="Apple-style-span" face="'trebuchet ms', sans-serif"><font class="Apple-style-span" color="#003333"><br></font></font></div><div><font class="Apple-style-span" face="'trebuchet ms', sans-serif"><font class="Apple-style-span" color="#003333">drop :: (Course, Student) -> </font></font><span class="Apple-style-span" style="font-family: 'trebuchet ms', sans-serif; "><i><font color="#003333"><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: arial; font-style: normal; "><div style="display: inline !important; ">
<font class="Apple-style-span" face="'trebuchet ms', sans-serif"><font class="Apple-style-span" color="#003333"><span class="Apple-style-span" style="color: rgb(0, 0, 0); "><i><font color="#003333"><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: arial; font-style: normal; "><div style="display: inline !important; ">
<span class="Apple-style-span" style="font-family: 'trebuchet ms', sans-serif; "><i><font color="#003333"><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: arial; font-style: normal; "><div style="display: inline !important; ">
<font class="Apple-style-span" face="'trebuchet ms', sans-serif"><font class="Apple-style-span" color="#003333">(Course, Student)</font></font></div></span></font></i></span></div></span></font></i></span></font></font></div>
</span></font></i></span></div><div><font class="Apple-style-span" face="'trebuchet ms', sans-serif"><font class="Apple-style-span" color="#003333"><br></font></font></div><div><font class="Apple-style-span" face="'trebuchet ms', sans-serif"><font class="Apple-style-span" color="#003333">I'm declaring the function as pair to pair because both change.</font></font></div>
<div><font class="Apple-style-span" face="'trebuchet ms', sans-serif"><font class="Apple-style-span" color="#003333"><br></font></font></div><div><font class="Apple-style-span" face="'trebuchet ms', sans-serif"><font class="Apple-style-span" color="#003333">If I run drop, I get a new Course record and a new Student record. Doesn't that mean I have to change all the Student, Instructor, and Course </font></font><span class="Apple-style-span" style="font-family: 'trebuchet ms', sans-serif; "><i><font color="#003333"><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: arial; font-style: normal; "><div style="display: inline !important; ">
<font class="Apple-style-span" face="'trebuchet ms', sans-serif"><font class="Apple-style-span" color="#003333"><span class="Apple-style-span" style="color: rgb(0, 0, 0); "><i><font color="#003333"><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: arial; font-style: normal; "><div style="display: inline !important; ">
<font class="Apple-style-span" face="'trebuchet ms', sans-serif"><font class="Apple-style-span" color="#003333">record</font></font></div></span></font></i></span></font></font></div></span></font></i></span><span class="Apple-style-span" style="font-family: 'trebuchet ms', sans-serif; "><i><font color="#003333"><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: arial; font-style: normal; "><div style="display: inline !important; ">
<font class="Apple-style-span" face="'trebuchet ms', sans-serif"><font class="Apple-style-span" color="#003333">s that refer to them, which also means I have to change all the Course </font></font></div></span></font></i></span><span class="Apple-style-span" style="font-family: 'trebuchet ms', sans-serif; "><i><font color="#003333"><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: arial; font-style: normal; "><div style="display: inline !important; ">
<span class="Apple-style-span" style="font-family: 'trebuchet ms', sans-serif; "><i><font color="#003333"><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: arial; font-style: normal; "><div style="display: inline !important; ">
<font class="Apple-style-span" face="'trebuchet ms', sans-serif"><font class="Apple-style-span" color="#003333"><span class="Apple-style-span" style="color: rgb(0, 0, 0); "><i><font color="#003333"><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: arial; font-style: normal; "><div style="display: inline !important; ">
<font class="Apple-style-span" face="'trebuchet ms', sans-serif"><font class="Apple-style-span" color="#003333">record</font></font></div></span></font></i></span></font></font></div></span></font></i></span></div>
</span></font></i></span><span class="Apple-style-span" style="font-family: 'trebuchet ms', sans-serif; "><i><font color="#003333"><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: arial; font-style: normal; "><div style="display: inline !important; ">
<span class="Apple-style-span" style="font-family: 'trebuchet ms', sans-serif; "><i><font color="#003333"><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: arial; font-style: normal; "><div style="display: inline !important; ">
<font class="Apple-style-span" face="'trebuchet ms', sans-serif"><font class="Apple-style-span" color="#003333">s that refer to them, etc.?</font></font></div></span></font></i></span></div></span></font></i></span></div>
<div><font class="Apple-style-span" face="'trebuchet ms', sans-serif"><font class="Apple-style-span" color="#003333"><br></font></font></div><div><font class="Apple-style-span" face="'trebuchet ms', sans-serif"><font class="Apple-style-span" color="#003333">Wouldn't I have to write something like this?</font></font></div>
<div><font class="Apple-style-span" face="'trebuchet ms', sans-serif"><font class="Apple-style-span" color="#003333"><br></font></font></div><div><font class="Apple-style-span" face="'trebuchet ms', sans-serif"><font class="Apple-style-span" color="#003333"><span class="Apple-style-span" style="color: rgb(0, 0, 0); "><i><font color="#003333"><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: arial; font-style: normal; "><div>
<font class="Apple-style-span" face="'trebuchet ms', sans-serif"><font class="Apple-style-span" color="#003333">data DataBase = DB { students :: [Student]</font></font></div><div><font class="Apple-style-span" face="'trebuchet ms', sans-serif"><font class="Apple-style-span" color="#003333"> , instructors :: [Instructor]</font></font></div>
<div><font class="Apple-style-span" face="'trebuchet ms', sans-serif"><font class="Apple-style-span" color="#003333"> , courses :: [Course]</font></font></div><div><font class="Apple-style-span" face="'trebuchet ms', sans-serif"><font class="Apple-style-span" color="#003333"> }</font></font></div>
<div><font class="Apple-style-span" color="#003333" face="'trebuchet ms', sans-serif"><br></font></div></span></font></i></span></font></font></div><div><font class="Apple-style-span" face="'trebuchet ms', sans-serif"><font class="Apple-style-span" color="#003333"><span class="Apple-style-span" style="color: rgb(0, 0, 0); "><i><font color="#003333"><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: arial; font-style: normal; "><div>
<font class="Apple-style-span" face="'trebuchet ms', sans-serif"><font class="Apple-style-span" color="#003333">drop :: DB -> Course -> Student -> </font></font><span class="Apple-style-span" style="font-family: 'trebuchet ms', sans-serif; "><i><font color="#003333"><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: arial; font-style: normal; "><div style="display: inline !important; ">
<font class="Apple-style-span" face="'trebuchet ms', sans-serif"><font class="Apple-style-span" color="#003333"><span class="Apple-style-span" style="color: rgb(0, 0, 0); "><i><font color="#003333"><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: arial; font-style: normal; "><div style="display: inline !important; ">
<font class="Apple-style-span" face="'trebuchet ms', sans-serif"><font class="Apple-style-span" color="#003333"><span class="Apple-style-span" style="color: rgb(0, 0, 0); "><i><font color="#003333"><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: arial; font-style: normal; "><div style="display: inline !important; ">
<font class="Apple-style-span" face="'trebuchet ms', sans-serif"><font class="Apple-style-span" color="#003333"><span class="Apple-style-span" style="color: rgb(0, 0, 0); "><i><font color="#003333"><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: arial; font-style: normal; "><div style="display: inline !important; ">
<span class="Apple-style-span" style="font-family: 'trebuchet ms', sans-serif; "><i><font color="#003333"><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: arial; font-style: normal; "><div style="display: inline !important; ">
<font class="Apple-style-span" face="'trebuchet ms', sans-serif"><font class="Apple-style-span" color="#003333"><span class="Apple-style-span" style="color: rgb(0, 0, 0); "><i><font color="#003333"><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: arial; font-style: normal; "><div style="display: inline !important; ">
<font class="Apple-style-span" face="'trebuchet ms', sans-serif"><font class="Apple-style-span" color="#003333">DB </font></font></div></span></font></i></span></font></font></div></span></font></i></span></div></span></font></i></span></font></font></div>
</span></font></i></span></font></font></div></span></font></i></span></font></font></div></span></font></i></span></div><div><span class="Apple-style-span" style="font-family: 'trebuchet ms', sans-serif; "><i><font color="#003333"><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: arial; font-style: normal; "><div style="display: inline !important; ">
<font class="Apple-style-span" face="'trebuchet ms', sans-serif"><font class="Apple-style-span" color="#003333"><span class="Apple-style-span" style="color: rgb(0, 0, 0); "><i><font color="#003333"><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: arial; font-style: normal; "><div style="display: inline !important; ">
<font class="Apple-style-span" face="'trebuchet ms', sans-serif"><font class="Apple-style-span" color="#003333"><span class="Apple-style-span" style="color: rgb(0, 0, 0); "><i><font color="#003333"><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: arial; font-style: normal; "><div style="display: inline !important; ">
<font class="Apple-style-span" face="'trebuchet ms', sans-serif"><font class="Apple-style-span" color="#003333"><span class="Apple-style-span" style="color: rgb(0, 0, 0); "><i><font color="#003333"><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: arial; font-style: normal; "><div style="display: inline !important; ">
<span class="Apple-style-span" style="font-family: 'trebuchet ms', sans-serif; "><i><font color="#003333"><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: arial; font-style: normal; "><div style="display: inline !important; ">
<font class="Apple-style-span" face="'trebuchet ms', sans-serif"><font class="Apple-style-span" color="#003333"><span class="Apple-style-span" style="color: rgb(0, 0, 0); "><i><font color="#003333"><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: arial; font-style: normal; "><div style="display: inline !important; ">
<font class="Apple-style-span" face="'trebuchet ms', sans-serif"><font class="Apple-style-span" color="#003333"><br></font></font></div></span></font></i></span></font></font></div></span></font></i></span></div>
</span></font></i></span></font></font></div>
</span></font></i></span></font></font></div></span></font></i></span></font></font></div></span></font></i></span></div><div><span class="Apple-style-span" style="font-family: 'trebuchet ms', sans-serif; "><i><font color="#003333"><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: arial; font-style: normal; "><div style="display: inline !important; ">
<font class="Apple-style-span" face="'trebuchet ms', sans-serif"><font class="Apple-style-span" color="#003333"><span class="Apple-style-span" style="color: rgb(0, 0, 0); "><i><font color="#003333"><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: arial; font-style: normal; "><div style="display: inline !important; ">
<font class="Apple-style-span" face="'trebuchet ms', sans-serif"><font class="Apple-style-span" color="#003333"><span class="Apple-style-span" style="color: rgb(0, 0, 0); "><i><font color="#003333"><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: arial; font-style: normal; "><div style="display: inline !important; ">
<font class="Apple-style-span" face="'trebuchet ms', sans-serif"><font class="Apple-style-span" color="#003333"><span class="Apple-style-span" style="color: rgb(0, 0, 0); "><i><font color="#003333"><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: arial; font-style: normal; "><div style="display: inline !important; ">
<span class="Apple-style-span" style="font-family: 'trebuchet ms', sans-serif; "><i><font color="#003333"><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: arial; font-style: normal; "><div style="display: inline !important; ">
<font class="Apple-style-span" face="'trebuchet ms', sans-serif"><font class="Apple-style-span" color="#003333"><span class="Apple-style-span" style="color: rgb(0, 0, 0); "><i><font color="#003333"><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: arial; font-style: normal; "><div style="display: inline !important; ">
<font class="Apple-style-span" face="'trebuchet ms', sans-serif"><font class="Apple-style-span" color="#003333">But even if I do that, doesn't that require a lot of code to get everything updated? </font></font></div>
</span></font></i></span></font></font></div></span></font></i></span></div></span></font></i></span></font></font></div></span></font></i></span></font></font></div></span></font></i></span></font></font></div></span></font></i></span><span class="Apple-style-span" style="font-family: 'trebuchet ms', sans-serif; "><i><font color="#003333"><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: arial; font-style: normal; "><div style="display: inline !important; ">
<font class="Apple-style-span" face="'trebuchet ms', sans-serif"><font class="Apple-style-span" color="#003333"><span class="Apple-style-span" style="color: rgb(0, 0, 0); "><i><font color="#003333"><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: arial; font-style: normal; "><div style="display: inline !important; ">
<font class="Apple-style-span" color="#003333" face="'trebuchet ms', sans-serif">Is there a simple way to write that function? </font></div></span></font></i></span></font></font></div></span></font></i></span></div>
<div><span class="Apple-style-span" style="font-family: 'trebuchet ms', sans-serif; "><i><font color="#003333"><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: arial; font-style: normal; "><div style="display: inline !important; ">
<span class="Apple-style-span" style="font-family: 'trebuchet ms', sans-serif; color: rgb(0, 51, 51); "><br></span></div></span></font></i></span></div><div><span class="Apple-style-span" style="font-family: 'trebuchet ms', sans-serif; "><i><font color="#003333"><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: arial; font-style: normal; "><div style="display: inline !important; ">
<span class="Apple-style-span" style="font-family: 'trebuchet ms', sans-serif; color: rgb(0, 51, 51); ">In a previous message I guessed that the best way to do it is with Maps, e.g. Map Student [Course] etc.</span></div>
</span></font></i></span></div><div><span class="Apple-style-span" style="font-family: 'trebuchet ms', sans-serif; "><i><font color="#003333"><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: arial; font-style: normal; "><div style="display: inline !important; ">
<span class="Apple-style-span" style="font-family: 'trebuchet ms', sans-serif; color: rgb(0, 51, 51); "><br></span></div></span></font></i></span></div><div><span class="Apple-style-span" style="font-family: 'trebuchet ms', sans-serif; "><i><font color="#003333"><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: arial; font-style: normal; "><div style="display: inline !important; ">
<span class="Apple-style-span" style="font-family: 'trebuchet ms', sans-serif; color: rgb(0, 51, 51); "><span class="Apple-style-span" style="color: rgb(0, 0, 0); "><i><font color="#003333"><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: arial; font-style: normal; "><div>
<font class="Apple-style-span" face="'trebuchet ms', sans-serif"><font class="Apple-style-span" color="#003333"><span class="Apple-style-span" style="color: rgb(0, 0, 0); "><i><font color="#003333"><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: arial; font-style: normal; "><div>
<span class="Apple-style-span" style="font-family: 'trebuchet ms', sans-serif; "><i><font color="#003333"><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: arial; font-style: normal; "><div style="display: inline !important; ">
<span class="Apple-style-span" style="font-family: 'trebuchet ms', sans-serif; color: rgb(0, 51, 51); ">I'd very much appreciate seeing the recommended code for the drop function. Thanks.</span></div></span></font></i></span></div>
</span></font></i></span></font></font></div></span></font></i></span></span></div></span></font></i></span></div></span></font></i></span></font></font><div dir="ltr"><font><font face="'trebuchet ms', sans-serif"><i><font color="#003333"><br>
</font></i></font></font></div></div></span></font></i></font></font></div></div><div><span class="Apple-style-span" style="font-family: 'trebuchet ms', sans-serif; "><i><font color="#003333">-- Russ</font></i></span></div>
<div>
<br></div><div><font class="Apple-style-span" face="'trebuchet ms', sans-serif"><font class="Apple-style-span" color="#003333">P.S. I'll admit that I've spent virtually no time with monads and would prefer to avoid them if possible. </font></font></div>
</div>