main|[uuuuuuuuu,iiiiiiiiiiiii,iiiiiiiiiiii,iiiiiiiiiii,iiiiiiiiii,iiiiiiiii,iiiiiiii,iiiiiii,iiiiii,iiiii,iiii,iii,ii,i,nnnnnnn,nnnnnn,nnnnn,uuuuuuuu,nnnn,uuuuuuu,aaaaaaaaaaaaai,aaaaaaaaaaaai,aaaaaaaaaaai,aaaaaaaaaai,aaaaaaaaai,aaaaaaaai,aaaaaaai,aaaaaai,aaaaai,aaaai,aaai,aai,ai,aaaaaaaaaaaaa,aaaaaaaaaaaa,aaaaaaaaaaa,aaaaaaaaaa,aaaaaaaaa,aaaaaaaa,aaaaaaa,aaaaaa,aaaaa,aaaa,aaa,aa,a,mmmmmmmmmmmmmmm,mmmmmmmmmmmmmm,uuuuuu,uuuuu,uuuu,mmmmmmmmmmmmm,mmmmmmmmmmmm,mmmmmmmmmm,mmmmmmmmm,mmmmmmmm,mmmmmmm,mmmmmm,mmmmm,mmmm,mmm,mm,m,pppppppppppp,uuu,uu,u,ppppppppppp,pppppppppp,ppppppppp,pppppppp,ppppppp,pppppp,ppppp,pppp,ppp,pp,p,nnn,urrrrrrrrrrrrrrrrrrrrrr,urrrrrrrrrrrrrrrrrrrrrrrr,urrrrrrrrrrrrrrrrrrrr,urrrrrrrrrrrrrrrrrrr,urrrrrrrrrrrrrrrrrr,urrrrrrrrrrrrrrrrr,urrrrrrrrrrrrrrrr,urrrrrrrrrrrrrr,urrrrrrrrrrrrr,urrrrrrrrrrrr,urrrrrrrrrrr,urrrrrrrrrr,urrrrrrrrr,urrrrrrrr,urrrrrrr,urrrrrr,urrrrr,urrrr,urrr,urr,ur,nn,n,rrrrrrrrrr,rrrrrrrrr,rrrrrrrr,rrrrrrr,rrrrrr,rrrrr,rrrr,rrr,rr]<-['n','m'..],[t,tt,ttt,tttt,ttttt,tttttt,ttttttt,tttttttt,ttttttttt,tttttttttt,ttttttttttt,tttttttttttt,ttttttttttttt,r]<-['n'..'{'],h<-putChar.minimum=h[n]>>h[nn]>>h[nnn]>>h[p]>>h[pp]>>h[ppp]>>h[pppp]>>h[ppppp]>>h[pppppp]>>h[pppppppp]>>h[ppppppppp]>>h[pppppppppp]>>h[ppppppppppp]>>h[pppppppppppp]>>h[m]>>h[mm]>>h[mmm]>>h[mmmm]>>h[mmmmm]>>h[mmmmmm]>>h[mmmmmmm]>>h[mmmmmmmm]>>h[mmmmmmmmm]>>h[mmmmmmmmmm]>>h[mmmmmmmmmmmm]>>h[mmmmmmmmmmmmmm]>>h[mmmmmmmmmmmmm]>>h[mmmmmmmmmmmmmmm]>>h[aa]>>h[aaaaa]>>h[aaaa]>>h[a]>>h[aaaaaa]>>h[aaaaaaa]>>h[aaaaaaaa]>>h[aaaaaaaaa]>>h[aaaaaaaaaa]>>h[aaaaaaaaaaa]>>h[aaaaaaaaaaaa]>>h[aaaaaaaaaaaaa]>>h[ai]>>h[aai]>>h[aaai]>>h[aaaai]>>h[aaaaai]>>h[aaaaaai]>>h[aaaaaaai]>>h[aaaaaaaai]>>h[aaaaaaaaai]>>h[aaaaaaaaaai]>>h[aaaaaaaaaaai]>>h[aaaaaaaaaaaai]>>h[aaaaaaaaaaaaai]>>h[nnnn]>>h[nnnnn]>>h[nnnnnn]>>h[nnnnnnn]>>h[ii]>>h[iii]>>h[iiii]>>h[iiiii]>>h[iiiiii]>>h[iiiiiii]>>h[iiiiiiiiii]>>h[iiiiiiiiiii]>>h[iiiiiiiiiiii]>>h[tt]>>h[tttt]>>h[tttttt]>>h[ttttttttt]>>h[tttttttttt]>>h[ttttttttttt]>>h[tttttttttttt]>>h[ttttttttttttt]
Try it online!
Probably not quite the intended method. minimum
ends up been crucial to my method. It is used as a replacement for head
.
How it works
This uses pattern guards on main
to pattern match the char
from two lists. One generated by ['n','m',..]
, and one generated by ['n'..'{']
.
Since function application is hard unless the arguemnt is a list, we create a function (called h
) that is putChar
modified to work with singleton lists. This is done by composing putChar
and minimum
in a pattern guard.
The body of main
is just applying h
to each character that we have matched and combing the IO actions with (>>)
.