Merge branch 'develop' into bump-dep-map

This commit is contained in:
Elliot Cameron 2020-06-22 10:16:44 -04:00 committed by GitHub
commit 8024960773
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 32 additions and 139 deletions

12
LICENSE Normal file
View File

@ -0,0 +1,12 @@
Copyright (c) 2020, Obsidian Systems LLC
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View File

@ -1,21 +1,21 @@
## [Reflex-DOM](https://reflex-frp.org)
[![Hackage](https://img.shields.io/hackage/v/reflex-dom.svg)](http://hackage.haskell.org/package/reflex-dom)
[![Haskell](https://img.shields.io/badge/language-Haskell-orange.svg)](https://haskell.org) [![Hackage](https://img.shields.io/hackage/v/reflex-dom.svg)](https://hackage.haskell.org/package/reflex-dom) [![Hackage CI](https://matrix.hackage.haskell.org/api/v2/packages/reflex-dom/badge)](https://matrix.hackage.haskell.org/#/package/reflex-dom) [![BSD3 License](https://img.shields.io/badge/license-BSD3-blue.svg)](https://github.com/reflex-frp/reflex-dom/blob/master/LICENSE)
### A Framework for Functional Reactive Web Apps in Haskell
Web applications without callbacks or side-effects. Reflex-DOM brings the power of [Functional Reactive Programming (FRP)](https://wiki.haskell.org/Functional_Reactive_Programming) to the web. Build [HTML](https://developer.mozilla.org/en-US/docs/Web/HTML) and other [Document Object Model (DOM)](https://developer.mozilla.org/en-US/docs/Web/API/Document_Object_Model) data with a pure functional interface.
Reflex-DOM is a framework for building web applications in Haskell, based on the [Functional Reactive Programming](https://wiki.haskell.org/Functional_Reactive_Programming) library [Reflex](https://github.com/reflex-frp/reflex).
A summary of Reflex-DOM functions is available in the [quick reference](Quickref.md).
Reflex-DOM is a framework for building web applications in [Haskell](https://www.haskell.org/), based on the [Functional Reactive Programming](https://wiki.haskell.org/Functional_Reactive_Programming) library [Reflex](https://github.com/reflex-frp/reflex).
**Visit https://reflex-frp.org/ for more information, tutorials, documentation and [examples](https://examples.reflex-frp.org/).**
### Additional resources
[Get started with Reflex](https://github.com/reflex-frp/reflex-platform)
[/r/reflexfrp](https://www.reddit.com/r/reflexfrp)
[irc.freenode.net #reflex-frp](http://webchat.freenode.net?channels=%23reflex-frp&uio=d4)
* [Official Website](https://reflex-frp.org/)
* [Quick Reference](Quickref.md)
* [Obelisk](https://github.com/obsidiansystems/obelisk#obelisk): A framework built on Reflex and Reflex-DOM for functional reactive web and mobile applications, with batteries included.
* [Get started with Reflex](https://github.com/reflex-frp/reflex-platform)
* [/r/reflexfrp](https://www.reddit.com/r/reflexfrp)
* [irc.freenode.net #reflex-frp](http://webchat.freenode.net?channels=%23reflex-frp&uio=d4)
### Hacking

View File

@ -1,4 +1,4 @@
Copyright (c) 2019, Obsidian Systems LLC
Copyright (c) 2020, Obsidian Systems LLC
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

View File

@ -1,4 +1,4 @@
Copyright (c) 2015, Obsidian Systems LLC
Copyright (c) 2020, Obsidian Systems LLC
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

View File

@ -3,6 +3,10 @@ Name: reflex-dom-core
Version: 0.6.0.0
Synopsis: Functional Reactive Web Apps with Reflex
Description:
Web applications without callbacks or side-effects.
Reflex-DOM brings the power of functional reactive programming (FRP) to the web.
Build HTML and other Document Object Model (DOM) data with a pure functional interface.
.
Reflex-DOM is a Functional Reactive web framework based on the Reflex FRP engine: <https://reflex-frp.org/>.
.
The @reflex-dom@ package is a small wrapper around the @reflex-dom-core@ package. It pulls in the

View File

@ -1,4 +1,4 @@
Copyright (c) 2015, Obsidian Systems LLC
Copyright (c) 2020, Obsidian Systems LLC
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

View File

@ -3,6 +3,10 @@ Name: reflex-dom
Version: 0.6.0.0
Synopsis: Functional Reactive Web Apps with Reflex
Description:
Web applications without callbacks or side-effects.
Reflex-DOM brings the power of functional reactive programming (FRP) to the web.
Build HTML and other Document Object Model (DOM) data with a pure functional interface.
.
Reflex-DOM is a Functional Reactive web framework based on the Reflex FRP engine: <https://reflex-frp.org/>.
.
The @reflex-dom@ package is a small wrapper around the @reflex-dom-core@ package. It pulls in the

View File

@ -1,127 +0,0 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
import Control.Monad
import Control.Monad.Identity
import Control.Monad.Trans
import Reflex.Dom
import qualified Data.Text as T
import Control.Concurrent
import Control.Monad.State.Strict
import Data.Functor.Misc
import Data.Monoid
import Data.Word
import qualified Data.Map as Map
import qualified Data.Dependent.Map as DMap
import Data.Dependent.Sum
import qualified Reflex.Patch.DMapWithMove as PatchDMapWithMove
main :: IO ()
main = mainWidget w
w :: forall t m. (MonadWidget t m, DomRenderHook t m, MountableDomBuilder t m) => m ()
w = do
let slow :: forall m'. (MonadWidget t m', DomRenderHook t m') => m' ()
{-
performEventChain = do
postBuild <- delay 0 =<< getPostBuild
rec let maxN = 10000
n = leftmost [0 <$ postBuild, ffilter (<=maxN) $ succ <$> n']
n' <- performEvent $ return <$> n
pausedUntil $ ffilter (==maxN) n'
_ <- widgetHold (text "Starting") $ text . T.pack . show <$> n
return ()
-}
-- {- Many dyns
slow = elAttr "div" ("style" =: "position:relative;width:256px;height:256px") $ go maxDepth
where maxDepth = 6 :: Int
go 0 = blank
go n = void $ dyn $ pure $ do
let bgcolor = "rgba(0,0,0," <> T.pack (show (1 - (fromIntegral n / fromIntegral maxDepth) :: Double)) <> ")"
s pos = pos <> ";position:absolute;border:1px solid white;background-color:" <> bgcolor
elAttr "div" ("style" =: s "left:0;right:50%;top:0;bottom:50%") $ go $ pred n
elAttr "div" ("style" =: s "left:50%;right:0;top:0;bottom:50%") $ go $ pred n
elAttr "div" ("style" =: s "left:50%;right:0;top:50%;bottom:0") $ go $ pred n
elAttr "div" ("style" =: s "left:0;right:50%;top:50%;bottom:0") $ go $ pred n
-- -}
{- Many elDynAttrs
slow = do
let size = 64
replicateM_ size $ elAttr "div" ("style" =: ("height:4px;width:" <> T.pack (show (size*4)) <> "px;line-height:0;background-color:gray")) $ do
replicateM_ size $ elDynAttr "div" (pure $ "style" =: "display:inline-block;width:4px;height:4px;background-color:black") blank
-}
{- Many dynTexts
slow = el "table" $ do
let size = 64
replicateM_ size $ el "tr" $ do
replicateM_ size $ el "td" $ do
dynText $ pure "."
-}
{- Many simultaneous performEvents
slow = do
postBuild <- getPostBuild
replicateM_ ((2 :: Int) ^ (14 :: Int)) $ performEvent_ $ return () <$ postBuild
done <- performEvent $ return () <$ postBuild
_ <- widgetHold (text "Doing performEvent") $ text "Done" <$ done
return ()
-}
{-
slow = do
postBuild <- getPostBuild
postBuild' <- performEvent . (return () <$) =<< performEvent . (return () <$) =<< getPostBuild
let f x = Map.fromList [(n, x) | n <- [1 :: Int .. 4096]]
listHoldWithKey (f False) (f (Just True) <$ postBuild') $ \k -> \case
False -> do
text "X "
notReadyUntil =<< getPostBuild
True -> do
text ". "
return ()
-}
{-
slow = do
let f :: forall a. EitherTag () () a -> Const2 () () a -> m' (Const2 () () a)
f _ (Const2 ()) = do
notReadyUntil =<< delay 0.5 =<< getPostBuild
text "Done"
return $ Const2 ()
postBuild <- getPostBuild
traverseDMapWithKeyWithAdjustWithMove f (DMap.singleton LeftTag $ Const2 ()) $ (PatchDMapWithMove.moveDMapKey LeftTag RightTag) <$ postBuild
return ()
-}
{-
slow = do
let h x = do
liftIO $ putStrLn "render hook"
result <- x
liftIO $ putStrLn "render hook done"
return result
f :: forall a. Const2 () () a -> Identity a -> m' (Identity a)
f (Const2 ()) (Identity ()) = do
liftIO $ putStrLn "f"
widgetHold notReady . (blank <$) =<< delay 0.1 =<< getPostBuild
liftIO $ putStrLn "f done"
return $ Identity ()
withRenderHook h $ do
postBuild <- getPostBuild
_ <- traverseDMapWithKeyWithAdjust f mempty $ PatchDMap (DMap.singleton (Const2 () :: Const2 () () ()) (ComposeMaybe $ Just $ Identity ())) <$ postBuild
return ()
-}
el "div" $ do
draw <- button "Draw"
widgetHold blank $ ffor draw $ \_ -> do
_ <- untilReady (text "Loading...") slow
return ()
return ()
#ifdef EXPERIMENTAL_DEPENDENT_SUM_INSTANCES
instance {-# INCOHERENT #-} (Show (f a), Show (f b)) => ShowTag (EitherTag a b) f where
showTagToShow e _ = case e of
LeftTag -> id
RightTag -> id
#endif