Skip to content

Instantly share code, notes, and snippets.

@mightybyte
mightybyte / WidgetTypes.hs
Last active May 30, 2017 22:09
FRP Widgets
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

Keybase proof

I hereby claim:

  • I am mightybyte on github.
  • I am mightybyte (https://keybase.io/mightybyte) on keybase.
  • I have a public key whose fingerprint is E354 4097 9E03 BC59 CC6F 444A 0272 6879 EA3E 9B28

To claim this, I am signing this object:

@mightybyte
mightybyte / Main.hs
Last active March 20, 2018 05:50
Attaching reflex to a particular node
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE RecursiveDo #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies #-}
------------------------------------------------------------------------------
import Control.Concurrent
import Control.Monad
import Control.Monad.Trans
@mightybyte
mightybyte / gist:2472faa614fde892afae
Last active August 29, 2015 14:17
diagrams metafont problem
-- image: http://i.imgur.com/567RLZ2.png
squiggle :: Path V2 Double
squiggle = rotate ((-1)/4 @@ turn) $ metafont $
(4 ^& 1) .--.
(10 ^& 4) .--.
(15 ^& 5.2) .--.
(20 ^& 5) .--.
(25 ^& 3) .--.
(30 ^& 1.5) .--.
@mightybyte
mightybyte / gist:3f7dfd8b20b45bdc9dd9
Last active August 29, 2015 14:02
TODO list for snap and heist 1.0
  • Move Heist.SpliceAPI to map-syntax (https://github.com/mightybyte/map-syntax)

  • Add namespace support to heist

    This means that users will be able to specify a namespace under which Heist will operate. If the user specifies a namespace of "h", then the splice '"foo" ## fooSplice' will match the tag <h:foo>. This alone doesn't give us much benefit. But on top of that we will add checking so Heist will throw an error if it encounters any <h:...> tag that does not have a splice bound for it. This will be a big help in finding bugs caused by not having a splice bound.

@mightybyte
mightybyte / DateFormlets.hs
Created December 10, 2013 19:04
A collection of core date/time formlets for digestive-functors.
utcTimeFormlet :: Monad m
=> String
-- ^ Date format string
-> String
-- ^ Time format string
-> TimeZone
-> Formlet Text m UTCTime
utcTimeFormlet dFmt tFmt tz d =
localTimeToUTC tz <$> localTimeFormlet dFmt tFmt (utcToLocalTime tz <$> d)
@mightybyte
mightybyte / MonadPostgres.hs
Created March 16, 2013 00:59
Another attempt at formulating MonadPostgres
class MonadIO m => MonadPostgres m where
withConn :: (P.Connection -> m a) -> m a
getPooler :: m ((P.Connection -> m a) -> m a)
withPool :: (P.Connection -> m a) -> m a
withPool f = do
pooler <- getPooler
pooler f
@mightybyte
mightybyte / first.hs
Created October 1, 2012 14:11 — forked from adinapoli/first.hs
First attempt
loginUser
:: ByteString
-- ^ Username field
-> ByteString
-- ^ Password field
-> Maybe ByteString
-- ^ Remember field; Nothing if you want no remember function.
-> (AuthFailure -> Handler b (AuthManager b) ())
-- ^ Upon failure
-> Handler b (AuthManager b) ()
createUser :: Text -- ^ Username
-> ByteString -- ^ Password
-> Handler b (AuthManager b) (Either String AuthUser)
createUser "" _ = return $ Left "Username cannot be empty"
createUser unm pwd = withBackend $ \r -> do
u <- liftIO $ buildAuthUser r unm pwd
return $ Right u
Process: ghc [64219]
Path: /usr/local/Cellar/ghc/7.4.2/lib/ghc-7.4.2/ghc
Identifier: ghc
Version: ??? (???)
Code Type: X86-64 (Native)
Parent Process: bash [63980]
Date/Time: 2012-06-12 22:28:34.143 -0400
OS Version: Mac OS X 10.6.8 (10K549)
Report Version: 6