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
{-# LANGUAGE TemplateHaskell #-} | |
import Language.Haskell.TH | |
import Language.Haskell.TH.Lib hiding (rename) | |
import Control.Monad (liftM) | |
import Data.List (lookup) | |
import Data.Generics.Aliases (mkT) | |
import Data.Generics.Schemes (everywhere) | |
---------------------------------------------------------------- |
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
{-# LANGUAGE TemplateHaskell #-} | |
module Printf (printf) where | |
-- Импортируем инструментарий Template Haskell | |
import Language.Haskell.TH | |
-- | Шаблон для функции printf | |
-- Пример использования: | |
-- > putStrLn ( $(printf "Number %d is %s of %d.") 327 "square" (327^2) ) |
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
{-# LANGUAGE FunctionalDependencies #-} | |
{-# LANGUAGE MultiParamTypeClasses, FlexibleInstances, UndecidableInstances #-} | |
module Prolog (Petja, Vasja, Serg, Father, Son, GrandFather) where | |
data Petja = Petja | |
data Vasja = Vasja | |
data Serg = Serg |
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
module DecemberFair where | |
import Data.Maybe (listToMaybe) | |
import Data.List (permutations, nubBy) | |
-- only non-symetric permutations | |
permute :: (Eq a) => [a] -> [[a]] | |
permute = nubBy (\ys zs -> ys == (reverse zs)) . permutations | |
-- binary operators |
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
# assuming that this script lies in g8test/ folder of the root directory of a g8-template | |
cd g8test | |
g8 file://.. --name=template > /dev/null | |
echo "Template applied in g8test/template/" | |
cd template | |
echo "sbt test:" && sbt test | |
cd ../.. |
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
namespace FooNamespace | |
{ | |
class Class | |
{ | |
static void Method1(){} | |
static void Method2(){} | |
class InnerClass | |
{ | |
static void InnerMethod1(){} |
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] | |
... | |
name: foo_2.10 | |
cross-versioned: false | |
[scala] | |
version: 2.10.0 |
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
trait UnionOf[L <: HList] { | |
type Mix | |
type Out = not[Mix] | |
type is[O] = UnionAux[L, O] | |
} | |
/* Implicits for constructing union: */ | |
object UnionOf { | |
implicit val nil = | |
new UnionOf[HNil] { type Mix = not[Nothing] } |
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
object HListSubtract { | |
// We use here this construction: https://gist.github.com/laughedelic/6808000 | |
import UnionHList._ | |
// Filters an HList `L`, trowing away any elements, that are in the given union `U` | |
trait Filter[L <: HList, U] { | |
type Out <: HList | |
def apply(l: L): Out | |
} |
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
lazy val tagListSettings: Seq[Setting[_]] = | |
TagListPlugin.tagListSettings ++ Seq( | |
TagListKeys.tags := Set( | |
TagListPlugin.Tag("todo", TagListPlugin.Warn) | |
, TagListPlugin.Tag("fixme", TagListPlugin.Error) | |
) | |
) | |
OlderNewer