From a04f722eb1cd426f5285d7ab32e8670efd542446 Mon Sep 17 00:00:00 2001 From: samgd Date: Sat, 23 Jul 2016 15:50:53 +0200 Subject: Canonicalize file + initial if/for planning --- hakyll.cabal | 1 + src/Hakyll/Web/Template/Canonicalize.hs | 86 +++++++++++++++++++++++++++++++++ 2 files changed, 87 insertions(+) create mode 100644 src/Hakyll/Web/Template/Canonicalize.hs diff --git a/hakyll.cabal b/hakyll.cabal index 94727f4..b2d4ce5 100644 --- a/hakyll.cabal +++ b/hakyll.cabal @@ -117,6 +117,7 @@ Library Hakyll.Web.Paginate Hakyll.Web.Template Hakyll.Web.Template.Internal + Hakyll.Web.Template.Canonicalize Hakyll.Web.Template.Context Hakyll.Web.Template.List diff --git a/src/Hakyll/Web/Template/Canonicalize.hs b/src/Hakyll/Web/Template/Canonicalize.hs new file mode 100644 index 0000000..13f9d67 --- /dev/null +++ b/src/Hakyll/Web/Template/Canonicalize.hs @@ -0,0 +1,86 @@ +-------------------------------------------------------------------------------- +-- | TODO +module Hakyll.Web.Template.Canonicalize + ( canonicalize + ) where + + +-------------------------------------------------------------------------------- +import Hakyll.Web.Template.Internal + + +-------------------------------------------------------------------------------- +-- +-- Some initial implementation notes. Note: Not valid syntax etc. +-- +-- +-- Top level ONLY: +-- [TrimL, t, TrimR] = [t] +-- +-- Dedupe: +-- +-- List: +-- +-- [t1, TrimR, TrimR, t2] = [t1, TrimR, t2] +-- +-- [t1, TrimL, TrimL, t2] = [t1, TrimL, t2] +-- +-- If: +-- +-- [t1, TrimR, If ex [TrimR, t] e, t2] = [t1, If ex [TrimR, t] e, t2] +-- +-- [t1, If ex t [e, TrimL], TrimL, t2] = [t1, If ex t [e, TrimL], t2] +-- +-- [t1, If ex [t, TrimL] Nothing, TrimL, t2] = [t1, If ex [t, TrimL] Nothing, t2] +-- +-- For: +-- +-- [t1, TrimR, For e [TrimR, b] sep, t2] = [t1, For e [TrimR, b] sep, t2] +-- +-- [t1, For e b [sep, TrimL], TrimL, t2] = [t1, For e b [sep, TrimL], t2] +-- +-- [t1, For e [b, TrimL] Nothing, TrimL, t2] = [t1, For e [b, TrimL] Nothing, t2] +-- +-- +-- Sink: +-- +-- If: +-- +-- [t1, TrimR, If ex t e, t2] = [t1, If ex [TrimR, t] e, t2] +-- +-- [t1, If ex t e, TrimL, t2] = if isJust e +-- then [t1, If ex t [e, TrimL], t2] +-- else [t1, If ex [t, TrimL] e, t2] +-- +-- For: +-- +-- [t1, TrimR, For e b sep, t2] = [t1, For e [TrimR, b] sep, t2] +-- +-- [t1, For e b sep, TrimL, t2] = if isJust sep +-- then [t1, For e b [sep, TrimL], t2] +-- else [t1, For e [b, TrimL] sep, t2] +-- +-- +-- Shift/Lift: +-- +-- If: +-- +-- If ex [t1, TrimR] (Just e) = If ex t1 [TrimR, e] +-- +-- If ex [t1, TrimR] Nothing = [If ex t1 Nothing, TrimR] +-- +-- If ex t [TrimL, e] = If ex [t, TrimL] e +-- +-- +-- For: +-- +-- For e [t1, TrimR] (Just sep) = For e t1 [TrimR, sep] +-- +-- For e [t1, TrimR] Nothing = For e t1 [TrimR, sep] +-- +-- For e b [TrimL, sep] = For e [b, TrimL] sep +-- +-- +-- +canonicalize :: Template -> Template +canonicalize = undefined -- cgit v1.2.3