Skip to content

Commit 7c8b067

Browse files
committed
Merge pull request #4 from slamdata/nonempty
Switch to purescript-nonempty
2 parents 1254580 + ad119d8 commit 7c8b067

File tree

6 files changed

+23
-23
lines changed

6 files changed

+23
-23
lines changed

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"tests"
1818
],
1919
"dependencies": {
20-
"purescript-nonempty-arrays": "garyb/purescript-nonempty-array#0.7-updates",
20+
"purescript-nonempty": "^0.1.1",
2121
"purescript-profunctor": "^0.3.0",
2222
"purescript-strings": "^0.5.2",
2323
"purescript-these": "^0.3.0",

src/Css/Font.purs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import Css.Property
66
import Css.Size
77
import Css.String
88
import Css.Stylesheet
9-
import qualified Data.Array.NonEmpty as NEL
9+
import Data.NonEmpty
1010

1111
color :: Color -> Css
1212
color = key $ fromString "color"
@@ -19,8 +19,8 @@ instance valGenericFontFamily :: Val GenericFontFamily where
1919
sansSerif :: GenericFontFamily
2020
sansSerif = GenericFontFamily $ fromString "sans-serif"
2121

22-
fontFamily :: Array String -> NEL.NonEmpty GenericFontFamily -> Css
23-
fontFamily a b = key (fromString "font-family") <<< value $ (value <<< quote <$> a) <> NEL.toArray (value <$> b)
22+
fontFamily :: Array String -> NonEmpty Array GenericFontFamily -> Css
23+
fontFamily a b = key (fromString "font-family") <<< value $ (value <<< quote <$> a) <> oneOf (value <$> b)
2424

2525
fontSize :: forall a. Size a -> Css
2626
fontSize = key $ fromString "font-size"

src/Css/FontFace.purs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import Css.Property
55
import Css.String
66
import Css.Stylesheet
77
import Data.Maybe
8-
import qualified Data.Array.NonEmpty as NEL
8+
import Data.NonEmpty
99

1010
fontFaceFamily :: String -> Css
1111
fontFaceFamily = key (fromString "font-family") <<< Literal
@@ -32,5 +32,5 @@ instance valFontFaceSrc :: Val FontFaceSrc where
3232
value (FontFaceSrcUrl u f) = fromString $ "url(" <> quote u <> ")" <> maybe "" (\f' -> " format(" <> formatName f' <> ")") f
3333
value (FontFaceSrcLocal l) = fromString $ "local(" <> quote l <> ")"
3434

35-
fontFaceSrc :: NEL.NonEmpty FontFaceSrc -> Css
35+
fontFaceSrc :: NonEmpty Array FontFaceSrc -> Css
3636
fontFaceSrc = key $ fromString "src"

src/Css/Property.purs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import Data.Maybe
77
import Data.Monoid
88
import Data.Profunctor.Strong
99
import Data.Tuple
10-
import qualified Data.Array.NonEmpty as NEL
10+
import Data.NonEmpty
1111

1212
data Prefixed = Prefixed (Array (Tuple String String))
1313
| Plain String
@@ -74,8 +74,8 @@ instance valNumber :: Val Number where
7474
instance valList :: (Val a) => Val (Array a) where
7575
value = intercalate (fromString ", ") <<< (value <$>)
7676

77-
instance valNonEmpty :: (Val a) => Val (NEL.NonEmpty a) where
78-
value = value <<< NEL.toArray
77+
instance valNonEmpty :: (Val a) => Val (NonEmpty Array a) where
78+
value = value <<< oneOf
7979

8080
noCommas :: forall a. (Val a) => Array a -> Value
8181
noCommas = intercalate (fromString " ") <<< (value <$>)

src/Css/Render.purs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import Data.Maybe
1212
import Data.Monoid
1313
import Data.These
1414
import Data.Tuple
15-
import qualified Data.Array.NonEmpty as NEL
15+
import Data.NonEmpty
1616

1717
newtype Inline = Inline String
1818

@@ -58,7 +58,7 @@ query' :: MediaQuery -> Array App -> Array Rule -> Rendered
5858
query' q sel rs = Just <<< That <<< Sheet $ mediaQuery q <> " { " <> fromMaybe "" (renderedSheet $ rules sel rs) <> " }\n"
5959

6060
mediaQuery :: MediaQuery -> String
61-
mediaQuery (MediaQuery no ty fs) = "@media " <> mediaType ty <> NEL.sconcat ((" and " <>) <<< feature <$> fs)
61+
mediaQuery (MediaQuery no ty fs) = "@media " <> mediaType ty <> foldl1 (<>) ((" and " <>) <<< feature <$> fs)
6262

6363
mediaType :: MediaType -> String
6464
mediaType (MediaType (Value s)) = plain s
@@ -97,7 +97,7 @@ imp t = Just <<< That <<< Sheet <<< fromString $ "@import url(" <> t <> ");\n"
9797
rule' :: forall a. Array App -> Array (Tuple (Key a) Value) -> Rendered
9898
rule' sel props = maybe q o $ nel sel
9999
where p = props >>= collect
100-
q = (This <<< Inline <<< properties <<< NEL.toArray) <$> nel p
100+
q = (This <<< Inline <<< properties <<< oneOf) <$> nel p
101101
o sel' = Just <<< That <<< Sheet $ intercalate " " [selector (merger sel'), "{", properties p, "}"]
102102

103103
selector :: Selector -> String
@@ -131,13 +131,13 @@ properties :: Array (Either String (Tuple String String)) -> String
131131
properties xs = intercalate "; " $ sheetRules <$> xs
132132
where sheetRules = either (\_ -> mempty) (\(Tuple k v) -> mconcat [k, ": ", v])
133133

134-
merger :: NEL.NonEmpty App -> Selector
135-
merger (NEL.NonEmpty x xs) =
134+
merger :: NonEmpty Array App -> Selector
135+
merger (NonEmpty x xs) =
136136
case x of
137137
Child s -> maybe s (\xs' -> merger xs' |> s) $ nel xs
138138
Sub s -> maybe s (\xs' -> merger xs' ** s) $ nel xs
139139
Root s -> maybe s (\xs' -> s ** merger xs') $ nel xs
140-
Pop i -> maybe (element "TODO") merger <<< nel <<< NEL.drop i $ x NEL.:| xs
140+
Pop i -> maybe (element "TODO") merger <<< nel <<< drop i $ x : xs
141141
Self sheetRules -> maybe (star `with` sheetRules) (\xs' -> merger xs' `with` sheetRules) $ nel xs
142142

143143
predicate :: Predicate -> String
@@ -153,6 +153,6 @@ predicate (AttrHyph a v) = "[" <> a <> "|='" <> v <> "']"
153153
predicate (Pseudo a ) = ":" <> a
154154
predicate (PseudoFunc a p) = ":" <> a <> "(" <> intercalate "," p <> ")"
155155

156-
nel :: forall a. Array a -> Maybe (NEL.NonEmpty a)
156+
nel :: forall a. Array a -> Maybe (NonEmpty Array a)
157157
nel [] = Nothing
158-
nel xs = (\{ head: head, tail: tail } -> head NEL.:| tail) <$> uncons xs
158+
nel xs = (\{ head: head, tail: tail } -> head :| tail) <$> uncons xs

src/Css/Stylesheet.purs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ import Data.Array (singleton)
99
import Data.Maybe
1010
import Data.Profunctor.Strong
1111
import Data.Tuple
12-
import qualified Data.Array.NonEmpty as NEL
12+
import Data.NonEmpty
1313

1414
newtype MediaType = MediaType Value
1515

1616
data NotOrOnly = Not | Only
1717

18-
data MediaQuery = MediaQuery (Maybe NotOrOnly) MediaType (NEL.NonEmpty Feature)
18+
data MediaQuery = MediaQuery (Maybe NotOrOnly) MediaType (NonEmpty Array Feature)
1919

2020
data Feature = Feature String (Maybe Value)
2121

@@ -25,7 +25,7 @@ data App = Self Refinement
2525
| Child Selector
2626
| Sub Selector
2727

28-
data Keyframes = Keyframes String (NEL.NonEmpty (Tuple Number (Array Rule)))
28+
data Keyframes = Keyframes String (NonEmpty Array (Tuple Number (Array Rule)))
2929

3030
data Rule = Property (Key Unit) Value
3131
| Nested App (Array Rule)
@@ -65,14 +65,14 @@ infixr 5 ?
6565
(?) :: Selector -> Css -> Css
6666
(?) sel rs = rule $ Nested (Sub sel) (runS rs)
6767

68-
query :: MediaType -> NEL.NonEmpty Feature -> Css -> Css
68+
query :: MediaType -> NonEmpty Array Feature -> Css -> Css
6969
query ty fs = rule <<< Query (MediaQuery Nothing ty fs) <<< runS
7070

71-
keyframes :: String -> NEL.NonEmpty (Tuple Number Css) -> Css
71+
keyframes :: String -> NonEmpty Array (Tuple Number Css) -> Css
7272
keyframes n xs = rule $ Keyframe (Keyframes n (second runS <$> xs))
7373

7474
keyframesFromTo :: String -> Css -> Css -> Css
75-
keyframesFromTo n a b = keyframes n $ Tuple 0.0 a NEL.:| [Tuple 100.0 b]
75+
keyframesFromTo n a b = keyframes n $ Tuple 0.0 a :| [Tuple 100.0 b]
7676

7777
fontFace :: Css -> Css
7878
fontFace = rule <<< Face <<< runS

0 commit comments

Comments
 (0)