From 5e38d1dbdfc806c4c093ddadc2cd39474069d7ad Mon Sep 17 00:00:00 2001 From: Michael Trotter Date: Fri, 25 May 2018 12:36:55 -0600 Subject: [PATCH] Add Monoid instance for JSX (#38) --- generated-docs/React/Basic.md | 6 ++++++ src/React/Basic.purs | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/generated-docs/React/Basic.md b/generated-docs/React/Basic.md index 47e98d1..ae391c1 100644 --- a/generated-docs/React/Basic.md +++ b/generated-docs/React/Basic.md @@ -81,6 +81,12 @@ data JSX :: Type A virtual DOM element. +##### Instances +``` purescript +Semigroup JSX +Monoid JSX +``` + #### `ReactComponent` ``` purescript diff --git a/src/React/Basic.purs b/src/React/Basic.purs index 70b7c5f..0fe0df3 100644 --- a/src/React/Basic.purs +++ b/src/React/Basic.purs @@ -16,11 +16,18 @@ import Prelude import Control.Monad.Eff (Eff, kind Effect) import Control.Monad.Eff.Uncurried (EffFn3, mkEffFn3) import Data.Function.Uncurried (Fn2, Fn3, mkFn3, runFn2) +import Data.Monoid (class Monoid) import Unsafe.Coerce (unsafeCoerce) -- | A virtual DOM element. foreign import data JSX :: Type +instance semigroupJSX :: Semigroup JSX where + append a b = fragment [ a, b ] + +instance monoidJSX :: Monoid JSX where + mempty = empty + -- | A React component which can be used from JavaScript. foreign import data ReactComponent :: Type -> Type