Canonicalize file + initial if/for planning

This commit is contained in:
samgd 2016-07-23 15:50:53 +02:00
parent 9867094bd2
commit a04f722eb1
No known key found for this signature in database
GPG Key ID: E69F2FF86041ADB3
2 changed files with 87 additions and 0 deletions

View File

@ -117,6 +117,7 @@ Library
Hakyll.Web.Paginate Hakyll.Web.Paginate
Hakyll.Web.Template Hakyll.Web.Template
Hakyll.Web.Template.Internal Hakyll.Web.Template.Internal
Hakyll.Web.Template.Canonicalize
Hakyll.Web.Template.Context Hakyll.Web.Template.Context
Hakyll.Web.Template.List Hakyll.Web.Template.List

View File

@ -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