Skip to content

Instantly share code, notes, and snippets.

Avatar

Moritz Kiefer cocreature

View GitHub Profile
View gobl.cob
* Free form cobol is for hipsters, we use proper fixed form cobol.
IDENTIFICATION DIVISION.
PROGRAM-ID. gobl.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 hostname PIC X(10) VALUE "localhost" & x"00".
01 port BINARY-SHORT VALUE 7575.
01 gethostbyname-result POINTER SYNC.
01 hostent BASED.
View Test.hs
{-# LANGUAGE OverloadedStrings #-}
module Test where
import qualified Data.ByteArray
import qualified Data.ByteString
import qualified Data.ByteString.Char8
import qualified Data.ByteString.Base16
import qualified Data.Text
import qualified Data.Text.Encoding
import qualified Crypto.Hash
View GMapKey.daml
-- Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
-- SPDX-License-Identifier: Apache-2.0
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE ViewPatterns #-}
daml 1.2
module Main where
import DA.Generics
import DA.Next.Map
import DA.List
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`
You can’t perform that action at this time.