Rewrite endsState using foldRight
Add extend and toString to Path
Add from to Path