Run this example at 2925443.run-a-gist.herokuapp.com
TL;DR: This page (html, css, javascript, markdown) is being served from this gist using this server.
After working with AngularJS, which is totally awesome, I wanted a better way to share code snippets with the community. Something where the header declarations aren't hidden, so it's clear which version of angular you're using and whether zepto/jquery/underscore are loaded. I also wanted to use CoffeeScript, HAML and SCSS because that's what I use to write Goodfilms (my day job).
This HTML is being rendered from HAML, the CSS is being compiled from SCSS, the JS code is written in Coffeescript and even this here text is being compiled (in the browser) from a gist-hosted Markdown file.
This file contains hidden or 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
{-# LANGUAGE GADTs #-} | |
{-# LANGUAGE LambdaCase #-} | |
{-# LANGUAGE TypeFamilies #-} | |
{-# LANGUAGE UndecidableInstances #-} | |
{-# LANGUAGE GeneralizedNewtypeDeriving #-} | |
{-# LANGUAGE ExistentialQuantification #-} | |
{-# LANGUAGE ScopedTypeVariables #-} | |
{-# LANGUAGE RankNTypes #-} | |
This file contains hidden or 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
{-# LANGUAGE GADTs #-} | |
{-# LANGUAGE LambdaCase #-} | |
{-# LANGUAGE TypeFamilies #-} | |
{-# LANGUAGE UndecidableInstances #-} | |
{-# LANGUAGE GeneralizedNewtypeDeriving #-} | |
{-# LANGUAGE ExistentialQuantification #-} | |
{-# LANGUAGE ScopedTypeVariables #-} | |
{-# LANGUAGE RankNTypes #-} | |
This file contains hidden or 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
{-# LANGUAGE TemplateHaskell, FlexibleContexts, FlexibleInstances, GADTs, DataKinds, | |
TypeInType, KindSignatures, InstanceSigs, TypeOperators, | |
ConstraintKinds, RankNTypes, ScopedTypeVariables, TypeFamilies, | |
UndecidableInstances, MultiParamTypeClasses, TypeApplications, PartialTypeSignatures #-} | |
--{-# OPTIONS_GHC -fplugin GHC.TypeLits.Normalise -fplugin GHC.TypeLits.KnownNat.Solver #-} | |
-- Three attempts at implementing a 'concat' operation for arbitrary dimension tensors, | |
-- concat dim xs ys is valid only if tensor xs and tensor ys share the same shape | |
-- (except for the dimension being joined) |
This file contains hidden or 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
{-# LANGUAGE TemplateHaskell, FlexibleContexts, FlexibleInstances, GADTs, DataKinds, | |
TypeInType, KindSignatures, InstanceSigs, TypeOperators, | |
ConstraintKinds, RankNTypes, ScopedTypeVariables, TypeFamilies, | |
UndecidableInstances, MultiParamTypeClasses, TypeApplications, PartialTypeSignatures #-} | |
$(singletons [d| | |
data UNat = Zero | Succ UNat | |
deriving (Eq) | |
|]) |
This file contains hidden or 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
import Data.Type.Index | |
data Sum :: [Type] -> Type where | |
L :: x -> Sum (x : xs) | |
R :: Sum xs -> Sum (x : xs) | |
inj :: (Elem xs x) => x -> Sum xs | |
inj = inj' elemIndex |
This file contains hidden or 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
module SumF where | |
import GHC.Generics (Generic1) | |
import Data.Kind (Type, Constraint) | |
import Data.Proxy | |
import Data.Functor.Classes |
This file contains hidden or 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
timeout :: MonadWidget t m => (Event t a, Event t a) -> NominalDiffTime -> m (Event t a) | |
timeout (down, up) time = do | |
delayed <- delay time down | |
let timedOut = flip pushAlways down $ const $ mdo | |
isDown <- hold True (False <$ leftmost [up, delayed]) | |
return $ gate isDown delayed | |
switchHold never timedOut |
This file contains hidden or 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 ApplyKey b a where | |
F :: ApplyKey (a -> b) | |
A :: ApplyKey a |
OlderNewer