Questions tagged [language-extension]

This tag is used for documented features of a compiler or interpreter implementation that are not described by the language standard, as well as for the implementation of such features, and for the provision of language features (e. g. syntax highlighting) in an IDE.

48 questions
128
votes
1 answer

How do I enable language extensions from within GHCi?

I'm trying to enable XRankNTypes in GHCi. How do I do this?
Matt Fenwick
  • 48,199
  • 22
  • 128
  • 192
113
votes
4 answers

C++ Modules - why were they removed from C++0x? Will they be back later on?

I just discovered this old C++0x draft about modules in C++0x. The idea was to get out of the current .h/.cpp system by writing only .cpp files which would then generate module files during compilation, which would then in turn be used by the other…
Tomaka17
  • 4,832
  • 5
  • 29
  • 38
83
votes
4 answers

What's this C++ syntax that puts a brace-surrounded block where an expression is expected?

I came across this weird C++ program. #include using namespace std; int main() { int a = ({int x; cin >> x; x;}); cout << a; } Can anyone explain what is going on? What is this construct called?
79
votes
2 answers

DatatypeContexts Deprecated in Latest GHC: Why?

I was just doing some Haskell development and I recompiled some old code on a new version of GHC: The Glorious Glasgow Haskell Compilation System, version 7.2.1 And when I did I received the following error: Warning: -XDatatypeContexts is…
Robert Massaioli
  • 13,379
  • 7
  • 57
  • 73
63
votes
1 answer

Which Haskell (GHC) extensions should users use/avoid?

I have had the experience a few times now of having GHC tell me to use an extension, only to discover that when in using that extension I have made code far more complex when a simple refactor would have allowed me to stick with Haskell 98 (now…
John F. Miller
  • 26,961
  • 10
  • 71
  • 121
50
votes
3 answers

What does a && operator do when there is no left side in C?

I saw a program in C that had code like the following: static void *arr[1] = {&& varOne,&& varTwo,&& varThree}; varOne: printf("One") ; varTwo: printf("Two") ; varThree: printf("Three") ; I am confused about what the && does because there is…
Joshua
  • 547
  • 4
  • 6
36
votes
1 answer

What are the pitfalls of using FlexibleContexts and FlexibleInstances?

Since these flexible contexts and instances aren't available in the Haskell standard, I assume there are potential problems when using them. What are they? Can they lead to some ambiguity, undecidability, overlapping instances, etc.? There is a…
Petr
  • 62,528
  • 13
  • 153
  • 317
29
votes
2 answers

How would I extend the JavaScript language to support a new operator?

The answer to the question Is it possible to create custom operators in JavaScript? is not yet, but @Benjamin suggested that it would be possible to add a new operator using third party tools: It is possible to use third party tools like sweet.js…
Ionică Bizău
  • 109,027
  • 88
  • 289
  • 474
29
votes
1 answer

Can using UndecidableInstances pragma locally have global consequences on compilation termination?

Suppose a Haskell library designer decides to use UndecidableInstances for some reason. The library compiles fine. Now suppose some program uses the library (like defines some instances of its type classes), but doesn't use the extension. Can it…
Petr
  • 62,528
  • 13
  • 153
  • 317
22
votes
1 answer

How do you use TypeApplications in Haskell?

With -XTypeApplications in GHC 8.0, you can specify types explicitly with @ preceding function arguments. What types does it exactly specify, especially when several @ are introduced?
Shou
  • 1,879
  • 17
  • 29
20
votes
1 answer

Why isn't GeneralizedNewtypeDeriving a Safe Haskell?

From GHC's manual, Section Safe Language: Module boundary control — Haskell code compiled using the safe language is guaranteed to only access symbols that are publicly available to it through other modules export lists. An important part of this…
Petr
  • 62,528
  • 13
  • 153
  • 317
18
votes
1 answer

Breaking Data.Set integrity without GeneralizedNewtypeDeriving

The code below uses an unsafe GeneralizedNewtypeDeriving extension to break Data.Set by inserting different elements with different Ord instances: {-# LANGUAGE GeneralizedNewtypeDeriving #-} import Data.Set import System.Random class AlaInt i…
nponeccop
  • 13,527
  • 1
  • 44
  • 106
17
votes
1 answer

Using Overloaded Strings

OverloadedStrings extension is really very useful, however it has some downsides. Consider the following function definition: someFunction :: ToJSSTring a => a -> IO () someFunction = js_function . toJSSTring In this case when if I want to pass a…
Geradlus_RU
  • 1,466
  • 2
  • 20
  • 37
16
votes
2 answers

Implementing C# language extensions

Using systems such as Parallel Linq, it's possible to split up execution of anonymous functions, queries, etc across multiple cores and threads within a single machine. I'd like the ability to extend this to run across multiple machines using…
3Dave
  • 28,657
  • 18
  • 88
  • 151
15
votes
5 answers

Make All Types Constant by Default in C++

What is the simplest and least obtrusive way to indicate to the compiler, whether by means of compiler options, #defines, typedefs, or templates, that every time I say T, I really mean T const? I would prefer not to make use of an external…
1
2 3 4