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
Does realToFrac compile to a no-op for (CFloat <-> Float / CDouble <-> Double)? | |
(14:27:30) kosmikus: nh2: it'll be a noop in many situations. CDouble normally is a newtype wrapper around Double. There are GHC Rule pragmas that'll turn realToFrac between Double and CDouble into a realToFrac between Double and Double by applying the constructor. Applying the constructor is a no-op, and there's a Double/Double instance having id as implementation. | |
(14:28:17) kosmikus: nh2: that being said, it's known that while simple applications of newtype constructors are newtypes, that doesn't translate to all contexts (such as mapping the constructor over a datastructure, for example) | |
(14:28:55) FreeFull: kosmikus: realToFrac isn't part of a typeclass though, it is defined as realToFrac = fromRational . toRational | |
(14:30:37) kosmikus: FreeFull: hm, you're right, I've been looking at the wrong place. let's check again. | |
(14:32:38) nh2: kosmikus, FreeFull: I really hope that realToFrac has rewrite rules for Double/CDouble and |
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 FlexibleInstances, GeneralizedNewtypeDeriving #-} | |
newtype TimeUnit = TimeUnit Integer -- how many microseconds | |
deriving (Eq, Show, Num) | |
instance Num (TimeUnit -> TimeUnit) where | |
fromInteger n = \(TimeUnit scale) -> TimeUnit (n * scale) | |
-- a + b = ... -- task for you |
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
#!/bin/bash | |
# Creates a git repository called "testgit-generated" | |
# with two separate histories branching from the initial | |
# commit, each being 500 commits long. | |
# On top of each, we create 200 branches with one extra | |
# commit per branch. | |
# Should take around 30 seconds. | |
set -e |
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
import Criterion.Main | |
import Data.List (sort) | |
import Data.Vector (Vector, fromList, unsafeThaw) | |
import qualified Data.Vector.Mutable as VM | |
import Data.Vector.Algorithms.Heap (select) | |
import Control.Monad.ST (runST) | |
import Data.Maybe (fromJust) | |
kSmallest1 :: Int -> [Int] -> Int |
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
import Data.List (sort) | |
import qualified Data.Map as Map | |
import Distribution.PackDeps | |
import Control.Monad | |
main :: IO () | |
main = do | |
newest <- loadNewest | |
let reverses = getReverses newest |
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 BangPatterns, ScopedTypeVariables #-} | |
module Main (main) where | |
import Criterion.Main | |
import Control.Monad | |
import Data.Vector ((!), Vector) | |
import qualified Data.Vector as V | |
import qualified Data.Vector.Unboxed as U | |
import qualified Data.Vector.Unboxed.Mutable as UM |
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
#include <stdio.h> | |
int main(int argc, char const *argv[]) | |
{ | |
float f = 1.23; | |
int i = * (int *) &f; | |
printf("%d\n", i); | |
float f2 = * (float *) &f; |
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
import GHC.Generics | |
import Data.Typeable | |
deriving instance Show (f p) => Show (M1 i c f p) | |
deriving instance (Show (f p), Show (g p)) => Show ((f :*:g) p) | |
deriving instance (Show (f p), Show (g p)) => Show ((f :+:g) p) | |
deriving instance (Show c) => Show (K1 i c p) | |
deriving instance Show (V1 p) | |
deriving instance Show (U1 p) | |
deriving instance Show D |
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
nh2: does `#if MIN_VERSION_base(4,7,0)` fail when using ghci / do I need to build with cabal? I'm trying to get my packages 7.8-ready | |
thoughtpolice: that macro is only defined by Cabal, IIRC. so yes, you do need cabal | |
nh2: thoughtpolice: is what they describe in https://github.com/hesselink/flock/pull/1 a valid workaround, using __GLASGOW_HASKELL__? | |
carter: nh2: yup, only in cbal | |
carter: yes | |
thoughtpolice: nh2: sure, __GLASGOW_HASKELL__ should be fine, since the accompanying version of base is fixed anyway | |
thoughtpolice: nh2: so you probably want something like '#if __GLASGOW_HASKELL__ >= 708' | |
thoughtpolice: nh2: but note __GLASGOW_HASKELL__ does not account for the minor version, so you can't distinguish base 4.7.0.0 from 4.7.1.0 for example | |
thoughtpolice: (although i think historically we've never bumped an update like that - only very minor bumps per release) | |
carter: thoughtpolice: edward just pointed out to me that GHC doesn't expose GHC minor version cpp |
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 CPP #-} | |
{-# LANGUAGE NamedFieldPuns, RecordWildCards, LambdaCase, MultiWayIf, ScopedTypeVariables, TypeSynonymInstances #-} | |
{-# LANGUAGE DeriveGeneric, StandaloneDeriving, FlexibleContexts, TypeOperators, DeriveDataTypeable #-} | |
{-# LANGUAGE TypeFamilies #-} | |
{-# LANGUAGE TemplateHaskell #-} | |
{-# OPTIONS_GHC -fno-warn-orphans #-} | |
-- | Design notes: | |
-- | |
-- * All matrices are right-multiplied: `v' = x .* A`. |
OlderNewer