reset password
Author Message
mkuko
Posts: 13
Posted 10:21 Apr 05, 2019 |

Hi Class,

I'm a bit confused with Part A.i of the exercises, the Piponi blog section.

My confusion arises in Exercise 3 (also applies to 6 & 9) where he states:

Show that lift f * lift g = lift (f.g)

Specifically the (*). Does he want us to override the (*) operator to make it work like lift (f.g), or is this some other notation?

I'm not sure if I'm missing something simple here but any insight would be much appreciated.

Thank you.

 

 

bfazeli
Posts: 6
Posted 10:29 Apr 05, 2019 |

My understanding was that we’re to write up a proof to show that it holds.

mkuko
Posts: 13
Posted 10:33 Apr 05, 2019 |

That sort of makes sense.

Would you happen to know what lift f * lift g is implying here?

rabbott
Posts: 1649
Posted 12:17 Apr 05, 2019 |

Piponi defines the (*) operator just before Exercise 2.

Given a pair of debuggable functions, f' and g', we can now compose them together to make a new debuggable function bind f' . g'. Write this composition as f'*g'. Even though the output of g' is incompatible with the input of f' we still have a nice easy way to concatenate their operations. And this suggests another question: is there an 'identity' debuggable function. The ordinary identity has these properties: f . id = f and id . f = f. So we're looking for a debuggable function, call it unit, such that unit * f = f * unit = f. Obviously we'd expect it to produce the empty debugging string and otherwise act a bit like the identity.

He then goes on as follows.

Exercise Two

Define unit.


Solution

unit x = (x,"")

The unit allows us to 'lift' any function into a debuggable one. In fact, define

lift f x = (f x,"")

or more simply, lift f = unit . f. The lifted version does much the same as the original function and, quite reasonably, it produces the empty string as a side effect.

Last edited by rabbott at 12:33 Apr 05, 2019.