packages feed

laika 0.1.0 → 0.1.1

raw patch · 4 files changed

+42/−22 lines, 4 filesdep ~recordnew-component:exe:demo

Dependency ranges changed: record

Files

laika.cabal view
@@ -1,19 +1,24 @@ name:   laika version:-  0.1.0+  0.1.1 synopsis:   Minimalistic type-checked compile-time template engine description:   The library integrates flawlessly with Haskell's new -  <https://github.com/nikita-volkov/record first-class records>.+  <http://hackage.haskell.org/package/record first-class records>.   .-  It inherits a remarkable quality from the dogs however:+  It inherits a remarkable quality from the dogs:   unlike most other template engines   at compile time it barks at you whenever you do anything wrong in your templates.   Hence the title (from Russian "lai" means "bark").   Also it commemorates Laika, the hero dog,    which became the first animal to orbit Earth and died in space.+  .+  _This library is in experimental state._ +  _Detailed documentation will arrive with the first stable release._+stability:+  experimental category: homepage:   https://github.com/nikita-volkov/laika @@ -44,6 +49,11 @@     git://github.com/nikita-volkov/laika.git  +flag demo+  description: Build Demo+  default: False++ library   hs-source-dirs:     library@@ -73,16 +83,11 @@     either >= 4.3 && < 4.4,     transformers >= 0.3 && < 0.5,     ---    record >= 0.1.1 && < 0.2,+    record >= 0.2 && < 0.3,     base-prelude >= 0.1 && < 0.2  --- Well, it's not a benchmark actually, --- but in Cabal there's no better way to specify an executable, --- which is not intended for distribution.-benchmark demo-  type: -    exitcode-stdio-1.0+executable demo   hs-source-dirs:     demo   main-is:@@ -97,8 +102,11 @@     Arrows, BangPatterns, ConstraintKinds, DataKinds, DefaultSignatures, DeriveDataTypeable, DeriveFunctor, DeriveGeneric, EmptyDataDecls, FlexibleContexts, FlexibleInstances, FunctionalDependencies, GADTs, GeneralizedNewtypeDeriving, ImpredicativeTypes, LambdaCase, LiberalTypeSynonyms, MagicHash, MultiParamTypeClasses, MultiWayIf, NoImplicitPrelude, NoMonomorphismRestriction, OverloadedStrings, PatternGuards, ParallelListComp, QuasiQuotes, RankNTypes, RecordWildCards, ScopedTypeVariables, StandaloneDeriving, TemplateHaskell, TupleSections, TypeFamilies, TypeOperators, UnboxedTuples   default-language:     Haskell2010-  build-depends:-    laika,-    text,-    record,-    base-prelude+  if !flag(demo)+    buildable: False+  else+    build-depends:+      laika,+      text,+      record,+      base-prelude
library/Laika.hs view
@@ -7,6 +7,7 @@ import Laika.Prelude import Language.Haskell.TH import qualified Record.Types+import qualified Record.Lens import qualified Data.Text as T import qualified Data.Text.Lazy as TL import qualified Data.Text.Lazy.Builder as TLB@@ -55,7 +56,7 @@           do             path' <- resolvePath path (view [l|path|] r)             return $-              bool id (AppE (AppE (VarE 'onLazyText) (VarE 'escapeHTML))) (view [l|escaped|] r) $+              bool id (AppE (AppE (VarE 'mapLazyText) (VarE 'escapeHTML))) (view [l|escaped|] r) $               pathValue path'         Parser.Block r ->           do@@ -70,8 +71,9 @@ pathValue :: Path -> Exp pathValue path =   foldr (\l r -> UInfixE l (VarE '($)) r) (VarE (mkName ("x" <> show argDepth))) .-  map (AppE (VarE 'Record.Types.getField) . -       SigE (ConE 'Record.Types.Field) . +  map (AppE (VarE 'Record.Lens.view) .+       AppE (VarE 'fieldSimpleLens) . +       SigE (VarE 'undefined) .         AppT (ConT ''Record.Types.Field) . LitT . StrTyLit . T.unpack) .   foldMap (\case Field n -> pure n; _ -> empty) .   takeWhile (/= Arg) @@ -80,8 +82,16 @@     argDepth =       length $ filter (== Arg) $ path -onLazyText :: (TL.Text -> TL.Text) -> TLB.Builder -> TLB.Builder-onLazyText f =+purifyQ :: Q a -> a+purifyQ = unsafePerformIO . runQ++fieldSimpleLens :: Record.Types.FieldLens n s s a a => +                   Record.Types.Field n -> Record.Lens.Lens s s a a+fieldSimpleLens = +  Record.Types.fieldLens++mapLazyText :: (TL.Text -> TL.Text) -> TLB.Builder -> TLB.Builder+mapLazyText f =   TLB.fromLazyText . f . TLB.toLazyText  escapeHTML :: TL.Text -> TL.Text
library/Laika/Lexer.hs view
@@ -153,7 +153,8 @@   BlockOpening Path |   BlockClosing |   Include FilePath -  deriving (Show)++deriving instance Show Token  tokens :: Lexer [Token] tokens = 
library/Laika/Parser.hs view
@@ -97,7 +97,8 @@   Text Text |    Reference Reference |   Block Block -  deriving (Show)++deriving instance Show Phrase  type Reference =   [r|{ escaped :: Bool, path :: Path }|]