Skip to content

Instantly share code, notes, and snippets.

module Read where
-- import Text.Read
readsData :: (String -> ReadS a) -> Int -> ReadS a
readsData reader d =
readParen (d > 10) $ \ r -> [res | (kw,s) <- lex r, res <- reader kw s]
readsUnaryWith :: (Int -> ReadS a) -> String -> (a -> t) -> String -> ReadS t
readsUnaryWith rp name cons kw s =
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE Unsafe #-}
{-# OPTIONS_GHC -Wno-redundant-constraints #-}
module CoercibleSumTypes (adtCoerce, ADTCoerce) where
import Data.Coerce (Coercible)
(define (map3 f ls)
(cond [(null? ls)
(values '() '() '())]
[else
(let-values ([(x1 x2 x3) (f (car ls))]
[(ls1 ls2 ls3) (map3 f (cdr ls))])
(values (cons x1 ls1) (cons x2 ls2) (cons x3 ls3)))]))

hmatrix issues

To get started, you'll need GHC 8.0.1 (I've also reproduced these issues with GHC HEAD, so that should work too). You'll also need the HEAD version of hmatrix. To do:

  1. git clone https://github.com/albertoruiz/hmatrix. (I'm using commit b32b37472559f202995e894f9a627871737d4619 at the moment.)

  2. Make sure you have OpenBLAS installed. I did pacman -S mingw-w64-x86_64-openblas. Apparently there are other ways to install OpenBLAS, but I haven't tried them.

  3. Apply the following change:

diff --git a/packages/base/hmatrix.cabal b/packages/base/hmatrix.cabal

@RyanGlScott
RyanGlScott / M.hs
Last active October 29, 2016 22:52
{-# LANGUAGE DefaultSignatures #-}
{-# LANGUAGE GADTs #-}
module M where
import Control.Monad.IO.Class
import Control.Monad.Trans.Reader
import qualified Control.Monad.Trans.Class as Trans
class (MonadIO m) => MonadLoggerIO m where

atomic-primops issues on Windows

atomic-primops is a package which has foreign imports of functions from the GHC runtime system, e.g.,

-- | Memory barrier implemented by the GHC rts (see SMP.h).
foreign import ccall  unsafe "store_load_barrier" storeLoadBarrier
  :: IO ()
module Main (main) where
import Numeric.LinearAlgebra (Matrix, I, step, (><))
mat :: Matrix I
mat = (3><4) [1..]
main :: IO ()
main = print $ step mat
This file has been truncated, but you can view the full file.
Mon Nov 28 19:47 2016 Time and Allocation Profiling Report (Final)
hlint +RTS -N -p -h -s -RTS
total time = 19.50 secs (19502 ticks @ 1000 us, 1 processor)
total alloc = 6,831,421,624 bytes (excludes profiling overheads)
COST CENTRE MODULE %time %alloc
happyDoAction Language.Haskell.Exts.InternalParser 57.7 1.5
This file has been truncated, but you can view the full file.
Mon Nov 28 19:57 2016 Time and Allocation Profiling Report (Final)
hlint +RTS -N -h -p -s -RTS
total time = 193.37 secs (193370 ticks @ 1000 us, 1 processor)
total alloc = 165,665,942,480 bytes (excludes profiling overheads)
COST CENTRE MODULE %time %alloc
uniplateData Data.Generics.Uniplate.Internal.Data 54.2 30.6
%!PS-Adobe-2.0
%%Title: hlint +RTS -N -p -h -s
%%Creator: hp2ps (version 0.25)
%%CreationDate: Mon Nov 28 19:47 2016
%%BoundingBox: 0 0 576 384
%%EndComments
0.888889 0.888889 scale
/HE10 /Helvetica findfont 10 scalefont def
/HE12 /Helvetica findfont 12 scalefont def
newpath