Skip to content

Instantly share code, notes, and snippets.

Avatar
🌚

Andrew / Kana kana-sama

🌚
View GitHub Profile
View lens.hs
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE RankNTypes #-}
module Main where
import Data.Functor.Const
import Data.Functor.Identity (Identity (..))
import Data.Monoid
data Profile = Profile {user :: User}
View insertion-sort-proved.hs
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE StandaloneKindSignatures #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE NoStarIsType #-}
View proved_nat.hs
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE StandaloneKindSignatures #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE NoStarIsType #-}
View twice . half of even = id.hs
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE StandaloneKindSignatures #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}
View dephaskell.hs
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
data Sigma a b
= forall (x :: a). MkSigma (b x)
type family Pi1 (x :: Sigma a b) :: a where
Pi1 (MkSigma @_ @_ @x _) = x
View path.hs
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
import Control.Lens
import Control.Monad (void)
import Data.Aeson
import Data.Aeson.Lens
import Data.Aeson.QQ.Simple
import Data.Char
View simplify.hs
import Data.Function (on)
import Data.List (groupBy, sortOn)
import Data.Maybe (mapMaybe)
data Expr
= Var String
| Const Integer
| Add Expr Expr
| Mul Expr Expr
deriving (Show)
View autowire.hs
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE UndecidableInstances #-}
-- HList lib
View loop example.hs
import Control.Arrow (loop)
replaceWithMax, replaceWithMax' :: Ord a => [a] -> [a]
replaceWithMax xs =
let (result, max) = go (xs, max)
in result
where
go ([], replacer) = ([], replacer)
go ([x], replacer) = ([replacer], x)
View qwe.ts
type NodeId = string;
type Node_ = {
id: NodeId,
label: string,
collapsed: boolean,
children: Node_[]
}
type Tree = Node_[]
You can’t perform that action at this time.