Skip to content

Instantly share code, notes, and snippets.

Moritz Kiefer cocreature

Block or report user

Report or block cocreature

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View LLVMTerminator.hs
{-# LANGUAGE RecursiveDo #-}
{-# LANGUAGE OverloadedStrings #-}
import qualified Data.ByteString.Char8 as BS
import Control.Monad.Fix
import LLVM
import LLVM.Context
import LLVM.AST hiding (function)
import LLVM.AST.Type as AST
import LLVM.IRBuilder.Constant
import LLVM.IRBuilder.Instruction
View ReflectOrd.hs
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE UndecidableInstances #-}
module ReflectOrd where
import Data.Reflection
import Data.Proxy
newtype Ordable s a = Ordable { unordable :: a }
View Convertible.hs
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE UndecidableInstances #-}
module Convertible where
import Control.Applicative
import Data.Proxy
View MegaparsecRecoveryEOF.hs
{-# LANGUAGE GADTs #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TupleSections #-}
import Control.Monad
import Data.Text (Text)
import Data.Void
import Text.Megaparsec
import Text.Megaparsec.Char
import qualified Text.Megaparsec.Char.Lexer as Lexer
View ExprSrcSpan.hs
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecursiveDo #-}
import Control.Monad
import Data.Text (Text)
import Data.Void
import Text.Megaparsec
import qualified Text.Megaparsec.Char.Lexer as Lexer
import Text.Megaparsec.Expr
type Parser = Parsec Void Text
View StrictAndLazyMonadFix.hs
-- This code will run into an infinite loop when the strict state
-- monad is used while it terminates just fine for the lazy state
-- monad. In particular monadic binds in the strict state monad cannot
-- depend on values defined later while this is possible in the lazy
-- state monad.
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE RecursiveDo #-}
{-# LANGUAGE BangPatterns #-}
module Main where
import Control.Monad.Fix
View Derangement.hs
-- This gist provides an explanation for why Haskell is significantly
-- faster than ATS and Rust in [vmchale’s great
-- benchmarks](https://github.com/vmchale/ats-benchmarks). What’s
-- happening is that the `derangements` list gets memoized so the
-- benchmark only checks the performance of (!!). `derangements'`
-- prevents GHC from memoizing the list and results in a significant
-- loss of performance. Criterion does try to prevent memoization but
-- it only prevents memoization of the function application (that’s
-- why the function and the argument need to be passed separately to
-- `nf`). It cannot prevent the memoization of the `derangements`
View InductionPls.v
Inductive ev_dumb : nat -> Prop :=
| EvDBase : ev_dumb 0
| EvDRec : forall n, ev_dumb n /\ n <> 1 -> ev_dumb (S (S n)).
Lemma ev_dumb_ind' :
forall P : nat -> Prop,
P 0 ->
(forall n : nat, P n -> ev_dumb n /\ n <> 1 -> P (S (S n))) ->
forall n : nat, ev_dumb n -> P n.
Proof.
View PipesAttoparsec.hs
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE NoImplicitPrelude #-}
import Protolude hiding (for)
import GHC.Base (String)
import Pipes
import qualified Pipes.Prelude as P
View HStoreList.hs
{-# LANGUAGE DeriveDataTypeable, DeriveGeneric, TupleSections #-}
import Data.Typeable
import Data.Aeson as Aeson
import Data.Text (Text)
import GHC.Generics
import qualified Data.HashMap.Lazy as LHM
newtype HStoreList = HStoreList {fromHStoreList :: [(Text,Text)]} deriving (Typeable, Eq, Show, Generic)
instance FromJSON HStoreList where
You can’t perform that action at this time.