ghc

How can I disable Haskell warning in small block?

心不动则不痛 提交于 2019-12-04 23:50:44
I want to disable warning only some block of code. I searched Google but only find file scope or global scope disable method. Using cabal file or pragma {-# OPTIONS_GHC #-} Can I disable warning for specific function? No, you can't currently in GHC 8.8.1 The {-# OPTIONS_GHC #-} pragma is file-header only and applies to the whole module. And there are no such pragmas (or other ways) to suppress warnings in specific locations. You can check the full list of pragmas in the Haskell user guide: https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/glasgow_exts.html#pragmas The list of

Type Family Shenanigans in GHCi

蹲街弑〆低调 提交于 2019-12-04 23:42:02
Here's my code: {-# LANGUAGE TypeFamilies, TypeOperators, DataKinds, PolyKinds, FlexibleContexts, UndecidableInstances #-} module Foo where import Data.Singletons.Prelude import Data.Type.Equality data TP a b -- foldl (\(bool, r) x -> (bool && (r == x), r)) (True, head xs) xs type family Same (b :: Bool) (r :: k) (rq :: [k]) :: k where Same bool r (x ': xs) = Same (bool :&& (r == x)) r xs Same bool r '[] = TP bool r data NotEqualFailure -- converts a True result to a type type family EqResult tp where EqResult (TP 'True r) = r EqResult (TP 'False r) = NotEqualFailure data Zq q i type family

Optimization of Function Calls in Haskell

自古美人都是妖i 提交于 2019-12-04 22:49:54
Not sure what exactly to google for this question, so I'll post it directly to SO: Variables in Haskell are immutable Pure functions should result in same values for same arguments From these two points it's possible to deduce that if you call somePureFunc somevar1 somevar2 in your code twice, it only makes sense to compute the value during the first call. The resulting value can be stored in some sort of a giant hash table (or something like that) and looked up during subsequent calls to the function. I have two questions: Does GHC actually do this kind of optimization? If it does, what is

What is the Haskell standard library?

懵懂的女人 提交于 2019-12-04 22:36:29
Can the GHC-specific libraries be called the standard library? Or do only those in the Haskell 2010 report count? Many of the GHC libraries can be implemented by the functions in the Haskell report, possibly combined with C bindings. But the others are reliant on GHC-specific extensions, since the current Haskell language as defined in the language report doesn't support it. For example, can Data.Array.IO be implemented in pure standard Haskell? Is it really okay to think that GHC is Haskell? Unfortunately the Haskell community doesn't have a real consensus about what's the "standard" library.

Are there any advantages of using Rank2Types in favor of RankNTypes?

≯℡__Kan透↙ 提交于 2019-12-04 22:16:52
As far as I know, a decidable type checking algorithm exists (only) for rank-2 types. Does GHC use somehow this fact, and does it have any practical implications? Is there also a notion of principal types for rank-2 types, and a type inference algorithm? If yes, does GHC use it? Are there any other advantages of rank-2 types over rank- n types? Rank2Types is a synonym for RankNTypes . So right now there are no advantages of rank-2 over rank-n. In principle type checking is decidable for rank 2 types. But, that was never going to be included in GHC (overly complicated, doesn't mix well with

Cabal install error: The package has a './configure' script. This requires a Unix

限于喜欢 提交于 2019-12-04 20:19:17
I'm trying to install network and old-time with cabal-install. When I try to install either it fails with: setup.exe: The package has a './configure' script. This requires a Unix compatibility toolchain such as MinGW+MSYS or Cygwin. I do have MinGW, in fact it's the MinGW distributed along with GHC. I've also added the bin folder to my PATH. How can I fix this? what tool is the one actually running the configure files? maybe I need to get it? GHC 7.10.1 x64 cabal-install version 1.22.0.0 using version 1.22.0.0 of the Cabal library. And I'm actually on a Windows 10 pro insider preview build

Summing a large list of numbers is too slow

会有一股神秘感。 提交于 2019-12-04 19:53:59
问题 Task: "Sum the first 15,000,000 even numbers." Haskell: nats = [1..] :: [Int] evens = filter even nats :: [Int] MySum:: Int MySum= sum $ take 15000000 evens ...but MySum takes ages. More precisely, about 10-20 times slower than C/C++. Many times I've found, that a Haskell solution coded naturally is something like 10 times slower than C. I expected that GHC was a very neatly optimizing compiler and task such this don't seem that tough. So, one would expect something like 1.5-2x slower than C.

Speed up compilation in GHC

老子叫甜甜 提交于 2019-12-04 19:09:33
问题 Is there options, except -O0 , that can speed up compilation time? It's not matter if resulting programs will be not optimised. Actually I want to just type-check large haskell package often and fast. Flag -fno-code dramatically speeds up compilation but it's not possible to use it because TemplateHaskell is used by this program. 回答1: Looks like a task for hdevtools! Hdevtools is used to as a backend for vim-plugin of the same name and it provides speedy syntax and type checking, directly

Storable empty data declaration

南笙酒味 提交于 2019-12-04 19:03:48
问题 I'm attempting to create a Haskell wrapper for a C library. The underlying structs are too complicated to express as explicit types, and I don't actually use them other than for passing between C functions, so I'm using EmptyDataDecls to let GHC work it out for me. What I need is a pointer to one of these data types, but when I attempt to create one with alloca it complains that the data is not of the type Storable . For example: {-# LANGUAGE ForeignFunctionInterface, EmptyDataDecls #-}

Why `(map digitToInt) . show` is so fast?

人盡茶涼 提交于 2019-12-04 18:41:31
问题 Converting non-negative Integer to its list of digits is commonly done like this: import Data.Char digits :: Integer -> [Int] digits = (map digitToInt) . show I was trying to find a more direct way to perform the task, without involving a string conversion, but I'm unable to come up with something faster. Things I've been trying so far: The baseline: digits :: Int -> [Int] digits = (map digitToInt) . show Got this one from another question on StackOverflow: digits2 :: Int -> [Int] digits2 =