added morphisms for Hask Functors

This commit is contained in:
Yann Esposito 2012-11-20 14:45:45 +01:00
parent c6987ee81d
commit 9d92e2d6c8
6 changed files with 117 additions and 14 deletions

View file

@ -0,0 +1,103 @@
pair int,bool,func,intlist,list;
resize(.8cm);
int=origin;
% drawoptions (withcolor baseOne withpen pencircle scaled 1.2);
intlist=int shifted (gu,0);
func=int shifted (0,-.6gu);
bool=func shifted (gu,0);
list=func shifted (2u,0);
pair decal;
pair fint,fbool,ffunc,fintlist,flist;
decal := (1.7gu,0);
fint=int shifted decal;
fintlist=intlist shifted decal;
ffunc= func shifted decal;
fbool= bool shifted decal;
flist= list shifted decal;
drawoptions(withcolor yellow withpen pencircle scaled 1);
drawLoopPoint(int,int shifted (0,1.6u),"\mathtt{sqrt}");
drawLoopPoint(fint,fint shifted (0,1.9u),"\scriptstyle\mathtt{fmap\ sqrt}");
drawoptions(withcolor green withpen pencircle scaled 1);
drawEdge(int,int,"\mathtt{id}");
drawEdge(fint,fint,"\scriptstyle\mathtt{fmap\ id}");
drawoptions(withcolor red withpen pencircle scaled 1);
drawEdgeAngle(int,bool,"\mathtt{odd}",-30);
drawEdgeAngle(fint,fbool,"\scriptstyle\mathtt{fmap\ odd}",-30);
drawoptions(withcolor magenta withpen pencircle scaled 1);
drawEdgeAngle(int,bool,"\mathtt{even}",30);
drawEdgeAngle(fint,fbool,"\scriptstyle\mathtt{fmap\ even}",30);
drawoptions(withcolor violet withpen pencircle scaled 1);
drawEdge(intlist,intlist,"\mathtt{tail}");
drawEdge(fintlist,fintlist,"\scriptstyle\mathtt{fmap\ tail}");
drawoptions(withcolor blue withpen pencircle scaled 1);
drawEdge(intlist,int,"\mathtt{head}");
drawEdge(fintlist,fint,"\scriptstyle\mathtt{fmap\ head}");
drawoptions(withcolor base1);
drawState(int,"\mathtt{Int}");
drawState(fint,"\mathtt{F\ Int}");
drawState(intlist,"\mathtt{[Int]}");
drawState(fintlist,"\mathtt{F\ [Int]}");
drawState(func,"\mathtt{a\rightarrow b}");
drawState(ffunc,"\mathtt{F\ a\rightarrow b}");
drawState(list,"\mathtt{[a]}");
drawState(flist,"\mathtt{F\ [a]}");
drawState(bool,"\mathtt{Bool}");
drawState(fbool,"\mathtt{F\ Bool}");
drawblock(fint,fbool,"\mathtt{F}");
% Draw blocks
pair ff;
ff = .5[fint,fintlist] shifted (0,u);
path b;
b := block(origin,origin);
draw b scaled .5 shifted ff;
label.top(btex $\mathtt{F\ F}$ etex, blockLabelPosition(b)) scaled .5 shifted ff;
draw b scaled .25 shifted ff;
label.top(btex $\mathtt{F\ F\ F}$ etex, blockLabelPosition(b)) scaled .25 shifted ff;
pair psqrt,pid,phead,podd,peven,ptail;
pair pfsqrt,pfid,pfhead,pfodd,pfeven,pftail;
psqrt := midpoint(loopPoint(int,int shifted (0,1.6u)));
pid := midpoint(edge(int,int));
podd := midpoint(edgeAngle(int,bool,-30));
peven := midpoint(edgeAngle(int,bool,30));
ptail := midpoint(edge(intlist,intlist));
phead := midpoint(edge(intlist,int));
pfsqrt := midpoint(loopPoint(fint,fint shifted (0,1.9u)));
pfid := midpoint(edge(fint,fint));
pfodd := midpoint(edgeAngle(fint,fbool,-30));
pfeven := midpoint(edgeAngle(fint,fbool,30));
pftail := midpoint(edge(fintlist,fintlist));
pfhead := midpoint(edge(fintlist,fint));
nodespace := 6bp;
drawoptions(withcolor yellow withpen pencircle scaled 1);
drawarrow edgeAngle(psqrt,pfsqrt,20) dashed evenly;
drawoptions(withcolor green withpen pencircle scaled 1);
drawarrow edgeAngle(pid,pfid,20) dashed evenly;
drawoptions(withcolor blue withpen pencircle scaled 1);
drawarrow edgeAngle(phead,pfhead,-20) dashed evenly;
drawoptions(withcolor red withpen pencircle scaled 1);
drawarrow edgeAngle(podd,pfodd,0) dashed evenly;
drawoptions(withcolor magenta withpen pencircle scaled 1);
drawarrow edgeAngle(peven,pfeven,-20) dashed evenly;
drawoptions(withcolor violet withpen pencircle scaled 1);
drawarrow edgeAngle(ptail,pftail,-5) dashed evenly;

Binary file not shown.

After

Width:  |  Height:  |  Size: 184 KiB

View file

@ -25,13 +25,13 @@ ffunc= func shifted decal;
fbool= bool shifted decal;
flist= list shifted decal;
drawLoopPoint(fint,fint shifted (0,1.9u),"\scriptstyle\mathtt{fmap\ sqrt}");
drawEdge(fint,fint,"\scriptstyle\mathtt{fmap\ id}");
drawEdgeAngle(fint,fbool,"\scriptstyle\mathtt{fmap\ odd}",-30);
drawEdgeAngle(fint,fbool,"\scriptstyle\mathtt{fmap\ even}",30);
drawEdge(fintlist,fintlist,"\scriptstyle\mathtt{fmap\ tail}");
drawEdge(fintlist,fint,"\scriptstyle\mathtt{fmap\ head}");
drawLoopPoint(fint,fint shifted (0,1.6u),"\mathtt{sqrt}");
drawEdge(fint,fint,"\mathtt{id}");
drawEdgeAngle(fint,fbool,"\mathtt{odd}",-30);
drawEdgeAngle(fint,fbool,"\mathtt{even}",30);
drawEdge(fintlist,fintlist,"\mathtt{tail}");
drawEdge(intlist,int,"\mathtt{head}");
drawblock(fint,fbool,"\mathtt{F}");
@ -55,7 +55,7 @@ drawState(intlist,"\mathtt{[Int]}");
drawState(fintlist,"\mathtt{F\ [Int]}");
drawoptions(withcolor blue withpen pencircle scaled 1);
drawarrow edgeAngle(func,ffunc,-25) dashed evenly;
drawarrow edgeAngle(func,ffunc,-20) dashed evenly;
drawState(func,"\mathtt{a\rightarrow b}");
drawState(ffunc,"\mathtt{F\ a\rightarrow b}");
@ -65,6 +65,6 @@ drawState(list,"\mathtt{[a]}");
drawState(flist,"\mathtt{F\ [a]}");
drawoptions(withcolor magenta withpen pencircle scaled 1);
drawarrow edgeAngle(bool,fbool,-25) dashed evenly;
drawarrow edgeAngle(bool,fbool,-20) dashed evenly;
drawState(bool,"\mathtt{Bool}");
drawState(fbool,"\mathtt{F\ Bool}");

Binary file not shown.

Before

Width:  |  Height:  |  Size: 167 KiB

After

Width:  |  Height:  |  Size: 182 KiB

View file

@ -26,12 +26,12 @@ fbool= bool shifted decal;
flist= list shifted decal;
drawLoopPoint(fint,fint shifted (0,1.6u),"\mathtt{sqrt}");
drawEdge(fint,fint,"\mathtt{id}");
drawEdgeAngle(fint,fbool,"\mathtt{odd}",-30);
drawEdgeAngle(fint,fbool,"\mathtt{even}",30);
drawEdge(fintlist,fintlist,"\mathtt{tail}");
drawEdge(intlist,int,"\mathtt{head}");
drawLoopPoint(fint,fint shifted (0,1.9u),"\scriptstyle\mathtt{fmap\ sqrt}");
drawEdge(fint,fint,"\scriptstyle\mathtt{fmap\ id}");
drawEdgeAngle(fint,fbool,"\scriptstyle\mathtt{fmap\ odd}",-30);
drawEdgeAngle(fint,fbool,"\scriptstyle\mathtt{fmap\ even}",30);
drawEdge(fintlist,fintlist,"\scriptstyle\mathtt{fmap\ tail}");
drawEdge(fintlist,fint,"\scriptstyle\mathtt{fmap\ head}");
drawblock(fint,fbool,"\mathtt{F}");

Binary file not shown.

Before

Width:  |  Height:  |  Size: 65 KiB

After

Width:  |  Height:  |  Size: 72 KiB