git.iko.soy/purestack-dev/purescript-plum
on master help sign in
renames
55621cciko
plum/src/Plum/View.purs+19−19
@@ -14,8 +14,8 @@ module Plum.View
14 , rgb
14 , rgb
15 , rgba
15 , rgba
16 , UI
16 , UI
17− , UIWith(..)
17+ , GenericUI(..)
18− , UIViewWith
18+ , GenericUIView
19 , column
19 , column
20 , row
20 , row
21 , stack
21 , stack
@@ -45,37 +45,37 @@ import Maquette as Maquette
45import Record as Record
45import Record as Record
46import Record.Unsafe.Union as Record
46import Record.Unsafe.Union as Record
47
47
48−type UIViewWith children msg = { nerves :: Array (Nerve msg), meat :: Array Meat, children :: children }
48+type GenericUIView children msg = { nerves :: Array (Nerve msg), meat :: Array Meat, children :: children }
49
49
50−type UIView msg = UIViewWith (Array (View msg)) msg
50+type UIView msg = GenericUIView (Array (View msg)) msg
51
51
52−data UIWith children msg a = UI (UIViewWith children msg) a
52+data GenericUI children msg a = UI (GenericUIView children msg) a
53
53
54−instance (Semigroup children, Semigroup a) => Semigroup (UIWith children msg a) where
54+instance (Semigroup children, Semigroup a) => Semigroup (GenericUI children msg a) where
55 append (UI v a) (UI v' a') = UI (v <> v') (a <> a')
55 append (UI v a) (UI v' a') = UI (v <> v') (a <> a')
56
56
57−instance (Monoid children, Monoid a) => Monoid (UIWith children msg a) where
57+instance (Monoid children, Monoid a) => Monoid (GenericUI children msg a) where
58 mempty = UI mempty mempty
58 mempty = UI mempty mempty
59
59
60−type UI msg a = UIWith (Array (View msg)) msg a
60+type UI msg a = GenericUI (Array (View msg)) msg a
61
61
62−instance Functor (UIWith children msg) where
62+instance Functor (GenericUI children msg) where
63 map f (UI v a) = UI v $ f a
63 map f (UI v a) = UI v $ f a
64
64
65−instance Monoid children => Apply (UIWith children msg) where
65+instance Monoid children => Apply (GenericUI children msg) where
66 apply (UI views f) (UI views' a) = UI (views <> views') (f a)
66 apply (UI views f) (UI views' a) = UI (views <> views') (f a)
67
67
68−instance Monoid children => Applicative (UIWith children msg) where
68+instance Monoid children => Applicative (GenericUI children msg) where
69 pure = UI mempty
69 pure = UI mempty
70
70
71−instance Monoid children => Bind (UIWith children msg) where
71+instance Monoid children => Bind (GenericUI children msg) where
72 bind (UI views a) f =
72 bind (UI views a) f =
73 let
73 let
74 UI views' b = f a
74 UI views' b = f a
75 in
75 in
76 UI (views <> views') b
76 UI (views <> views') b
77
77
78−instance Monoid children => Monad (UIWith children msg)
78+instance Monoid children => Monad (GenericUI children msg)
79
79
80column :: forall msg a. UI msg a -> UI msg a
80column :: forall msg a. UI msg a -> UI msg a
81column (UI { nerves, meat, children } a) =
81column (UI { nerves, meat, children } a) =
@@ -89,7 +89,7 @@ stack :: forall msg a. UI msg a -> UI msg a
89stack (UI { nerves, meat, children } a) =
89stack (UI { nerves, meat, children } a) =
90 UI (mempty :: UIView msg) { children = [ { meat, nerves, bones: Stack children } ] } a
90 UI (mempty :: UIView msg) { children = [ { meat, nerves, bones: Stack children } ] } a
91
91
92−text :: forall msg. String -> UIWith Unit msg Unit -> UI msg Unit
92+text :: forall msg. String -> GenericUI Unit msg Unit -> UI msg Unit
93text s (UI { nerves, meat } a) = UI (mempty :: UIView msg) { children = [ { meat, nerves, bones: Text s } ] } a
93text s (UI { nerves, meat } a) = UI (mempty :: UIView msg) { children = [ { meat, nerves, bones: Text s } ] } a
94
94
95link :: forall msg a. String -> UI msg a -> UI msg a
95link :: forall msg a. String -> UI msg a -> UI msg a
@@ -152,7 +152,7 @@ downloadAs url { filename } (UI { nerves, meat, children } a) = UI
152 }
152 }
153 a
153 a
154
154
155−image :: forall msg a. String -> { description :: String } -> UIWith Unit msg a -> UI msg a
155+image :: forall msg a. String -> { description :: String } -> GenericUI Unit msg a -> UI msg a
156image url description (UI { nerves, meat } a) =
156image url description (UI { nerves, meat } a) =
157 UI (mempty :: UIView msg) { children = [ { meat, nerves, bones: Image url description } ] } a
157 UI (mempty :: UIView msg) { children = [ { meat, nerves, bones: Image url description } ] } a
158
158
@@ -168,13 +168,13 @@ data Alignment = Start | Center | End
168
168
169data Direction = X | Y
169data Direction = X | Y
170
170
171−meat :: forall ch msg a. Monoid ch => Monoid a => Meat -> UIWith ch msg a
171+meat :: forall ch msg a. Monoid ch => Monoid a => Meat -> GenericUI ch msg a
172−meat m = UI (mempty :: UIViewWith ch msg) { meat = [ m ] } mempty
172+meat m = UI (mempty :: GenericUIView ch msg) { meat = [ m ] } mempty
173
173
174−spacing :: forall ch msg a. Monoid ch => Monoid a => { x :: Int, y :: Int } -> UIWith ch msg a
174+spacing :: forall ch msg a. Monoid ch => Monoid a => { x :: Int, y :: Int } -> GenericUI ch msg a
175spacing { x, y } = meat $ Spacing x y
175spacing { x, y } = meat $ Spacing x y
176
176
177−explain :: forall ch msg a. Monoid ch => Monoid a => UIWith ch msg a
177+explain :: forall ch msg a. Monoid ch => Monoid a => GenericUI ch msg a
178explain = meat Explain
178explain = meat Explain
179
179
180data Meat
180data Meat