Created
November 19, 2020 16:15
-
-
Save exaexa/9920eb85d2bd20f4c575f2f1d307ae96 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data WithIndents a = Line a | Indent | Dedent deriving Show | |
unindent [0] [] = [] | |
unindent (_:xs) [] = Dedent:unindent xs [] | |
unindent is@(i:it) ss@((ci,s):st) | |
| ci>i = Indent : unindent (ci:is) ss | |
|ci==i = Line s : unindent is st | |
| ci<i = Dedent : unindent it ss | |
demo = unindent [0] [(0,"foo"),(2,"bar"),(1,"gah"),(1,"another")] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment