Skip to content

Instantly share code, notes, and snippets.

@benmos
benmos / gist:6934979
Last active December 25, 2015 06:49 — forked from anonymous/gist:6934958
module Main where
main :: IO ()
main = do
putStrLn "My second ever gist!"
-- You could add another line here:
putStrLn "The end!"
@benmos
benmos / Extras.hs
Last active December 25, 2015 06:49 — forked from anonymous/gist:6934958
module Extras(
-- * Functions
calculateEverything
)
where
calculateEverything :: () -> Int
calculateEverything _ = 42
@benmos
benmos / default.nix
Created July 20, 2014 11:20
Nix troubles on OS X
let cfg = pkgs : {
packageOverrides = pkgs : rec {
#
# 'localHaskellPackages' contains not only the packages which we're explicitly
# adding / modifying below, but also versions of the normal 'haskellPackages'
# which make use of our modified packages instead of the default versions.
#
# At the time of writing, we only have additions rather than overrides per-se,
# but this will probably be a useful feature in the future.
#
-- | This is a variant of 'simpleList' which manages a current selection.
-- The 'Bool' accepted by the rendering function indicates whether the
-- element in question is currently selected or not.
selectList :: forall t m a i . (Eq i, MonadWidget t m) =>
(a -> i) -> Dynamic t [a] -> (Dynamic t (a, Bool) -> m (Event t i)) -> m (Event t i)
selectList getItem ds fn = mdo
let ev :: Event t i
ev = switch $ fmap leftmost $ current evs
markSel :: [a] -> Maybe i -> [(a,Bool)]
data AppState = AppState {
_asFeeds :: M.Map BordersFeed BFeedState,
_asSelectedFeed :: Maybe BordersFeed
}
$(makeLenses ''AppState)
data AppEvent = FeedFetched (BordersFeed, String)
| FeedSelected BordersFeed
@benmos
benmos / reflex.hs
Last active December 11, 2015 19:05
-- Compute URL for opening new tab with the corresponding new post in it
let npUrl np = "/postinfo?seq=" <> T.pack (show $ newSeq np) <> "&owner=" <> webAdminToolDevice
webAdminToolDevice = "WebAdminTool" -- FIXME - should share code with Borders.Base.Model.Core
eurl :: Event t T.Text
eurl = fmapMaybe (fmap npUrl . snd) (enpresult :: Event t (BordersNewPost, Maybe BordersNewPostResult))
durl <- holdReset eurl (() <$ updated darticle) :: m (Dynamic t (Maybe T.Text))
--dynText =<< mapDyn (("durl:"<>) . show) durl