mirror of https://git.sr.ht/~solsen/rose
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
17 lines
418 B
17 lines
418 B
module Rose.Data.Match |
|
|
|
import Data.SExpression |
|
import Util |
|
|
|
data Match : Type where |
|
MkMatch : List (List SE, SE) -> Match |
|
|
|
fromExpression : SE -> Match |
|
-- ([x] (foo) [y] (bar)) |
|
-- [(x), (foo), ...] |
|
fromExpression e = |
|
case toList e of |
|
[] => MkMatch [] |
|
xs => MkMatch $ zipper (evenPositions xs) (oddPositions xs) |
|
where zipper : List SE -> List (List SE, SE) |
|
zipper xs ys = zip (map toList xs) ys
|
|
|