Skip to content

Instantly share code, notes, and snippets.

{-# LANGUAGE FlexibleInstances, UndecidableInstances, ContextConstraints #-}
{- in response to http://www.reddit.com/r/haskell/comments/bxdi2/ask_what_would_be_your_dream_xs/c0p1r55 -}
import Control.Monad
class Func m where
func :: m Int -> m Int
instance (Monad m) => Func m where
@softmechanics
softmechanics / sendTempFile.hs
Created October 22, 2010 16:33
send and delete a file with Yesod
{-# LANGUAGE TemplateHaskell
, QuasiQuotes
, OverloadedStrings
, TypeFamilies
#-}
import Yesod
import Yesod.Handler
import Data.Maybe
@softmechanics
softmechanics / CombineForm.hs
Created November 19, 2010 07:30
Combine multiple Yesod Forms into one.
{-# LANGUAGE FlexibleInstances
, FlexibleContexts
, MultiParamTypeClasses
, TypeSynonymInstances
, FunctionalDependencies
, UndecidableInstances
#-}
module CombineForm where
import Yesod
@softmechanics
softmechanics / directingTI.hs
Created December 1, 2010 20:37
Directing type inference with equality constraints and multi parameter type classes
{-# LANGUAGE MultiParamTypeClasses
, FlexibleInstances
, TypeFamilies
#-}
class Add a b where
add :: a -> b -> a
instance Num a => Add a a where
add = (+)
{-# LANGUAGE FlexibleInstances
, FlexibleContexts
, MultiParamTypeClasses
, TypeSynonymInstances
, FunctionalDependencies
, UndecidableInstances
#-}
module CombineForm where
import Yesod
@softmechanics
softmechanics / formMonadWithoutSignature.hs
Created December 26, 2010 08:23
Yesod: Using GFormMonad without a type signature
{-# LANGUAGE QuasiQuotes, OverloadedStrings, TemplateHaskell, TypeFamilies #-}
import Control.Applicative
import Yesod
import Yesod.Form.Core
data CommentForm = CommentForm
{ user :: String
, comment :: Textarea
, isHtml :: Bool
}
@softmechanics
softmechanics / fileFieldTest.hs
Created January 3, 2011 02:13
Example of Yesod's fileField
{-# LANGUAGE QuasiQuotes
, OverloadedStrings
, TypeFamilies
#-}
import Yesod
import Control.Applicative
data Test = Test
{-# LANGUAGE QuasiQuotes
, TemplateHaskell
, OverloadedStrings
, TypeFamilies
#-}
import Yesod
import Yesod.Form
import Yesod.Form.Jquery
import Control.Applicative
@softmechanics
softmechanics / timepicker.html
Created January 20, 2011 19:23
jquery-ui-timepicker-addon test
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title></title>
<script src="http://trentrichardson.com/examples/timepicker/js/jquery-1.4.4.min.js"
type="text/javascript">
</script>
<script src=
"http://trentrichardson.com/examples/timepicker/js/jquery-ui-1.8.6.custom.min.js"
import Control.Concurrent
import Control.Exception
import Control.Monad
import Network.Socket
main = forever $ do
pair <- try $ socketPair AF_UNIX Stream defaultProtocol
case pair of
Left e -> do
let _ = e :: SomeException