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
-- Paste this into http://hsnippet.com after adding Reflex.Dom.Contrib.Widgets.DynamicList | |
-- to the imports list in HSnippet's imports tab. | |
app :: MonadWidget t m => App t m () | |
app = do | |
addItem <- button "Add Item" | |
dynamicList single snd (const never) ("edit me" <$ addItem) | |
["alpha", "bravo", "charlie"] | |
return () |
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
data CurAppState = Login | Home | Other | |
app :: MonadWidget t m => CurAppState -> m () | |
app Login = ... | |
app Home = ... | |
app Other = ... | |
navBar :: MonadWidget t m => m (Event t CurAppState) | |
navBar = do | |
a <- button "Login" |
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
newtype AceRef = AceRef { unAceRef :: JSVal } | |
data ACE t = ACE | |
{ aceRef :: AceRef | |
, aceValue :: Dynamic t String | |
} | |
------------------------------------------------------------------------------ | |
startACE :: String -> IO AceRef | |
#ifdef ghcjs_HOST_OS |
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
(define-syntax elAttr | |
(syntax-rules () | |
((elAttr tag attrs children ...) | |
(eval-element 'tag 'attrs 'children ...)))) | |
(define-syntax el | |
(syntax-rules () | |
((el tag children ...) | |
(elAttr tag () children ...)))) |
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
diff -r clock-0.5.1/System/Clock.hsc clock-0.5.2/System/Clock.hsc | |
173,177c173,175 | |
< normalize (TimeSpec xs xn) | |
< | xn < 0 || xn >= 10^9 = | |
< let (q, r) = xn `divMod` (10^9) | |
< in TimeSpec (xs + q) r | |
< | otherwise = TimeSpec xs xn | |
--- | |
> normalize (TimeSpec xs xn) | xn < 0 || xn >= 10^9 = TimeSpec (xs + q) r | |
> | otherwise = TimeSpec xs xn |
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
getArgs :: Type -> [Type] | |
getArgs (ForallT _ _ t) = getArgs t | |
getArgs (SigT t _) = getArgs t | |
getArgs (AppT (AppT ArrowT a) b) = a : getArgs b | |
getArgs b = [b] | |
-- Possible lens version | |
prismCase [ _ForallT . _3 :-> getArgs, _SigT . _1 :-> getArgs, _AppAppArrow :-> \(a,b) -> a : getArgs b, id :-> \b -> [b] ] |
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
app :: MonadWidget t m => App t m () | |
app = do | |
ti <- textInput $ TextInputConfig "range" "4" never | |
(constDyn $ "min" =: "1" <> "max" =: "6") | |
n <- holdDyn (4::Int) (read <$> updated (value ti)) | |
let f = reflexDia (def & sizeSpec .~ D.mkSizeSpec2D (Just 600) (Just 600)) . example | |
el "div" $ widgetHoldHelper f 4 (updated n) | |
return () | |
hilbert 0 = mempty |
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
------------------------------------------------------------------------------ | |
-- | Gets the current path of the DOM Window (i.e., the contents of the | |
-- address bar after the host, beginning with a "/"). | |
-- https://developer.mozilla.org/en-US/docs/Web/API/Location | |
getWindowLocationPathname :: DOMWindow -> IO String | |
#ifdef ghcjs_HOST_OS | |
getWindowLocationPathname w = do | |
jw <- toJSRef w | |
liftM fromJSString $ js_windowLocationPathname jw |
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
$ dist/build/cabal/cabal gen-bounds | |
Resolving dependencies... | |
The following packages need bounds and here is a suggested starting point. | |
You can copy and paste this into the build-depends section in your .cabal | |
file and it should work (with the appropriate removal of commas). | |
Note that version bounds are a statement that you've successfully built and | |
tested your package and expect it to work with any of the specified package | |
versions (PROVIDED that those packages continue to conform with the PVP). |
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
data WidgetConfig t a | |
= WidgetConfig { _widgetConfig_setValue :: Event t a | |
, _widgetConfig_initialValue :: a | |
, _widgetConfig_attributes :: Dynamic t (Map String String) | |
} | |
makeLenses ''WidgetConfig | |
instance (Reflex t, Default a) => Default (WidgetConfig t a) where | |
def = WidgetConfig { _widgetConfig_setValue = never |