-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #31 from hapytex/feature/ormolu
Feature/ormolu
- Loading branch information
Showing
11 changed files
with
225 additions
and
169 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,15 @@ | ||
{-| | ||
Module : Css.Selector | ||
Description : Css 3 selectors in Haskell. | ||
Maintainer : [email protected] | ||
Stability : experimental | ||
Portability : POSIX | ||
A module for backwards compatibility that re-exports 'Css3.Selector'. This module is deprecated and eventually will be removed. | ||
-} | ||
module Css.Selector {-# DEPRECATED "Use Css3.Selector instead" #-} ( | ||
module Css3.Selector, | ||
) where | ||
-- | | ||
-- Module : Css.Selector | ||
-- Description : Css 3 selectors in Haskell. | ||
-- Maintainer : [email protected] | ||
-- Stability : experimental | ||
-- Portability : POSIX | ||
-- | ||
-- A module for backwards compatibility that re-exports 'Css3.Selector'. This module is deprecated and eventually will be removed. | ||
module Css.Selector | ||
{-# DEPRECATED "Use Css3.Selector instead" #-} | ||
( module Css3.Selector, | ||
) | ||
where | ||
|
||
import Css3.Selector |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,15 @@ | ||
{-| | ||
Module : Css.Selector.Core | ||
Description : A module where we define the tree of types to represent and maniplate a css selector. | ||
Maintainer : [email protected] | ||
Stability : experimental | ||
Portability : POSIX | ||
A module for backwards compatibility that re-exports 'Css3.Selector.Core'. This module is deprecated and eventually will be removed. | ||
-} | ||
module Css.Selector.Core {-# DEPRECATED "Use Css3.Selector.Core instead" #-} ( | ||
module Css3.Selector.Core | ||
) where | ||
-- | | ||
-- Module : Css.Selector.Core | ||
-- Description : A module where we define the tree of types to represent and maniplate a css selector. | ||
-- Maintainer : [email protected] | ||
-- Stability : experimental | ||
-- Portability : POSIX | ||
-- | ||
-- A module for backwards compatibility that re-exports 'Css3.Selector.Core'. This module is deprecated and eventually will be removed. | ||
module Css.Selector.Core | ||
{-# DEPRECATED "Use Css3.Selector.Core instead" #-} | ||
( module Css3.Selector.Core, | ||
) | ||
where | ||
|
||
import Css3.Selector.Core |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,15 @@ | ||
{-| | ||
Module : Css.Selector.QuasiQuoters | ||
Description : A module that defines a quasiquoter to parse a string to a css selector. | ||
Maintainer : [email protected] | ||
Stability : experimental | ||
Portability : POSIX | ||
A module for backwards compatibility that re-exports 'Css3.Selector.QuasiQuoters'. This module is deprecated and eventually will be removed. | ||
-} | ||
module Css.Selector.QuasiQuoters {-# DEPRECATED "Use Css3.Selector.QuasiQuoters instead" #-} ( | ||
module Css3.Selector.QuasiQuoters | ||
) where | ||
-- | | ||
-- Module : Css.Selector.QuasiQuoters | ||
-- Description : A module that defines a quasiquoter to parse a string to a css selector. | ||
-- Maintainer : [email protected] | ||
-- Stability : experimental | ||
-- Portability : POSIX | ||
-- | ||
-- A module for backwards compatibility that re-exports 'Css3.Selector.QuasiQuoters'. This module is deprecated and eventually will be removed. | ||
module Css.Selector.QuasiQuoters | ||
{-# DEPRECATED "Use Css3.Selector.QuasiQuoters instead" #-} | ||
( module Css3.Selector.QuasiQuoters, | ||
) | ||
where | ||
|
||
import Css3.Selector.QuasiQuoters |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,15 @@ | ||
{-| | ||
Module : Css.Selector.Utils | ||
Description : A set of utility methods to encode and decode strings. | ||
Maintainer : [email protected] | ||
Stability : experimental | ||
Portability : POSIX | ||
A module for backwards compatibility that re-exports 'Css3.Selector.Utils'. This module is deprecated and eventually will be removed. | ||
-} | ||
module Css.Selector.Utils {-# DEPRECATED "Use Css3.Selector.Utils instead" #-} ( | ||
module Css3.Selector.Utils | ||
) where | ||
-- | | ||
-- Module : Css.Selector.Utils | ||
-- Description : A set of utility methods to encode and decode strings. | ||
-- Maintainer : [email protected] | ||
-- Stability : experimental | ||
-- Portability : POSIX | ||
-- | ||
-- A module for backwards compatibility that re-exports 'Css3.Selector.Utils'. This module is deprecated and eventually will be removed. | ||
module Css.Selector.Utils | ||
{-# DEPRECATED "Use Css3.Selector.Utils instead" #-} | ||
( module Css3.Selector.Utils, | ||
) | ||
where | ||
|
||
import Css3.Selector.Utils |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
{-| | ||
Module : Css3.Selector | ||
Description : Css 3 selectors in Haskell. | ||
Maintainer : [email protected] | ||
Stability : experimental | ||
Portability : POSIX | ||
A module to define css selectors by making use of a quasiquoter, and manipulating these css selectors. | ||
-} | ||
module Css3.Selector ( | ||
module Css3.Selector.Core, | ||
-- | | ||
-- Module : Css3.Selector | ||
-- Description : Css 3 selectors in Haskell. | ||
-- Maintainer : [email protected] | ||
-- Stability : experimental | ||
-- Portability : POSIX | ||
-- | ||
-- A module to define css selectors by making use of a quasiquoter, and manipulating these css selectors. | ||
module Css3.Selector | ||
( module Css3.Selector.Core, | ||
module Css3.Selector.QuasiQuoters, | ||
module Css3.Selector.Utils | ||
) where | ||
module Css3.Selector.Utils, | ||
) | ||
where | ||
|
||
import Css3.Selector.Core | ||
import Css3.Selector.QuasiQuoters | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,39 @@ | ||
{-# LANGUAGE TemplateHaskellQuotes #-} | ||
|
||
{-| | ||
Module : Css3.Selector.QuasiQuoters | ||
Description : A module that defines a quasiquoter to parse a string to a css selector. | ||
Maintainer : [email protected] | ||
Stability : experimental | ||
Portability : POSIX | ||
A module that defines a quasiquoter to parse a string to a css selector. | ||
-} | ||
module Css3.Selector.QuasiQuoters ( | ||
csssel, cssselFile, parseCss | ||
) where | ||
|
||
import Css3.Selector.Core(SelectorGroup, toPattern) | ||
import Css3.Selector.Lexer(alexScanTokens) | ||
import Css3.Selector.Parser(cssselector) | ||
|
||
import Data.Data(Data, cast) | ||
import Data.Text(pack, unpack) | ||
|
||
import Language.Haskell.TH.Quote(QuasiQuoter(QuasiQuoter, quoteExp, quotePat, quoteType, quoteDec), quoteFile) | ||
import Language.Haskell.TH.Syntax(Exp(AppE, VarE), Q, Type(ConT), dataToExpQ, lift, reportWarning) | ||
-- | | ||
-- Module : Css3.Selector.QuasiQuoters | ||
-- Description : A module that defines a quasiquoter to parse a string to a css selector. | ||
-- Maintainer : [email protected] | ||
-- Stability : experimental | ||
-- Portability : POSIX | ||
-- | ||
-- A module that defines a quasiquoter to parse a string to a css selector. | ||
module Css3.Selector.QuasiQuoters | ||
( csssel, | ||
cssselFile, | ||
parseCss, | ||
) | ||
where | ||
|
||
import Css3.Selector.Core (SelectorGroup, toPattern) | ||
import Css3.Selector.Lexer (alexScanTokens) | ||
import Css3.Selector.Parser (cssselector) | ||
import Data.Data (Data, cast) | ||
import Data.Text (pack, unpack) | ||
import Language.Haskell.TH.Quote (QuasiQuoter (QuasiQuoter, quoteDec, quoteExp, quotePat, quoteType), quoteFile) | ||
import Language.Haskell.TH.Syntax (Exp (AppE, VarE), Q, Type (ConT), dataToExpQ, lift, reportWarning) | ||
|
||
-- | Parse the string to a 'SelectorGroup'. | ||
parseCss :: String -- ^ The string to be parsed to a 'SelectorGroup' | ||
-> SelectorGroup -- ^ The selectorgroup that is the equivalent of the given 'String'. | ||
parseCss :: | ||
-- | The string to be parsed to a 'SelectorGroup' | ||
String -> | ||
-- | The selectorgroup that is the equivalent of the given 'String'. | ||
SelectorGroup | ||
parseCss st = al (alexScanTokens st') | ||
where st' = filter ('\r' /=) st | ||
al (Left er) = error er | ||
al (Right val) = cssselector val | ||
where | ||
st' = filter ('\r' /=) st | ||
al (Left er) = error er | ||
al (Right val) = cssselector val | ||
|
||
liftDataWithText :: Data a => a -> Q Exp | ||
liftDataWithText = dataToExpQ ((((AppE (VarE 'pack) <$>) . lift . unpack) <$>) . cast) | ||
|
@@ -38,12 +42,13 @@ liftDataWithText = dataToExpQ ((((AppE (VarE 'pack) <$>) . lift . unpack) <$>) . | |
-- css selector. In case the css selector is invalid. A compiler error will be | ||
-- thrown (at compile time). | ||
csssel :: QuasiQuoter | ||
csssel = QuasiQuoter { | ||
quoteExp = liftDataWithText . parseCss, | ||
quotePat = pure . toPattern . parseCss, | ||
quoteType = const (reportWarning "The type of the quasiquoter will always use the SelectorGroup type." >> pure (ConT ''SelectorGroup)), | ||
quoteDec = const (reportWarning "The use of this quasiquoter will not make any declarations." >> pure []) | ||
} | ||
csssel = | ||
QuasiQuoter | ||
{ quoteExp = liftDataWithText . parseCss, | ||
quotePat = pure . toPattern . parseCss, | ||
quoteType = const (reportWarning "The type of the quasiquoter will always use the SelectorGroup type." >> pure (ConT ''SelectorGroup)), | ||
quoteDec = const (reportWarning "The use of this quasiquoter will not make any declarations." >> pure []) | ||
} | ||
|
||
-- | A quasiquoter that takes the content from the file, and then runs the | ||
-- content of that file as a 'csssel' quasiquote. | ||
|
Oops, something went wrong.