Questions tagged [forall]

Haskell extension and keyword used to define rank-n and existentially quantified types or to use scoped type variables

forall is a keyword found in the programming language (with extensions), used in type specifications.

It can be used to define rank-n and existentially quantified types or to use scoped type variables. For more information, see What does the `forall` keyword in Haskell/GHC do?.

100 questions
342
votes
8 answers

What does the `forall` keyword in Haskell/GHC do?

I'm beginning to understand how the forall keyword is used in so-called "existential types" like this: data ShowBox = forall s. Show s => SB s This is only a subset, however, of how forall is used and I simply cannot wrap my mind around its use in…
JUST MY correct OPINION
  • 33,835
  • 16
  • 75
  • 95
48
votes
5 answers

forall in Scala

As shown below, in Haskell, it's possible to store in a list values with heterogeneous types with certain context bounds on them: data ShowBox = forall s. Show s => ShowBox s heteroList :: [ShowBox] heteroList = [ShowBox (), ShowBox 5, ShowBox…
missingfaktor
  • 86,952
  • 56
  • 271
  • 360
34
votes
4 answers

What does "exists" mean in Haskell type system?

I'm struggling to understand the exists keyword in relation to Haskell type system. As far as I know, there is no such keyword in Haskell by default, but: There are extensions which add them, in declarations like these data Accum a = exists s.…
Valentin Golev
  • 9,653
  • 8
  • 57
  • 79
17
votes
1 answer

What are these explicit "forall"s doing?

What is the purpose of the foralls in this code? class Monad m where (>>=) :: forall a b. m a -> (a -> m b) -> m b (>>) :: forall a b. m a -> m b -> m b -- Explicit for-alls so that we know what order to --…
Matt Fenwick
  • 44,546
  • 19
  • 115
  • 184
13
votes
1 answer

Explicit forall on a type class function

Since ghc-8.0 we have a very nice extension called TypeApplications. Which allows us instead of: λ> show (5 :: Int) "5" do so something like that: λ> :set -XTypeApplications λ> show @Int 5 "5" Which is really cool. It becomes a bit more involved…
lehins
  • 8,651
  • 2
  • 31
  • 45
12
votes
2 answers

Why does `forall (a :: j) (b:: k)` work differently than `forall (p :: (j,k))`?

I'm trying to understand the difference between using forall to quantify two type variables and using forall to quantify a single type variable of tuple kind. For example, given the following type families: {-# LANGUAGE RankNTypes #-} {-# LANGUAGE…
rampion
  • 82,104
  • 41
  • 185
  • 301
12
votes
1 answer

Using Contract.ForAll in Code Contracts

Okay, I have yet another Code Contracts question. I have a contract on an interface method that looks like this (other methods omitted for clarity): [ContractClassFor(typeof(IUnboundTagGroup))] public abstract class ContractForIUnboundTagGroup :…
Dan Bryant
  • 26,669
  • 3
  • 48
  • 98
11
votes
4 answers

Understanding forall in Monad '>>=' function?

Following this answer, I've implemented a generic lift function in my program: liftTupe :: (x -> c x) -> (a, b) -> (c a, c b) --This will error liftTuple :: (forall x. x -> c x) -> (a, b) -> (c a, c b) I understand, that in this context, forall is…
Babra Cunningham
  • 2,691
  • 1
  • 17
  • 44
10
votes
2 answers

Code contracts, forall and custom enumerable

I am using C# 4.0 and Code Contracts and I have my own custom GameRoomCollection : IEnumerable. I want to ensure, that no instances of GameRoomCollection will ever contain a null value element. I don't seem to be able to this, though.…
Stephan
  • 101
  • 4
8
votes
2 answers

Multiple SQL statements in FORALL loop

I want to insert in Different tables with only single FORALL Loop in oracle.but FORALL don't support it.any idea how can i do it?? create or replace PROCEDURE test IS TYPE avl_web_details IS TABLE OF available_web_details%ROWTYPE; …
Asha Koshti
  • 2,412
  • 4
  • 20
  • 30
7
votes
1 answer

How to add an extra project into existing Android operating system source?

I am working on kernel development in AOSP, and the kernel repository that I work on is not a part of the operating system. It has an individual git repository. So when I try to push all AOSP sources into the server, I cannot see the kernel sources…
albin
  • 771
  • 1
  • 7
  • 26
7
votes
2 answers

What does type signature for `undefined` mean in Haskell?

I am a beginner in Haskell and I am taken aback by the undefined function's type signature. I expected something more simple, but I found this on Hackage: undefined :: forall (r :: RuntimeRep). forall (a :: TYPE r). HasCallStack => a A special…
mkUltra
  • 2,382
  • 18
  • 38
6
votes
3 answers

How can I ensure that my Fortran FORALL construct is being parallelized?

I've been given a 2D matrix representing temperature points on the surface of a metal plate. The edges of the matrix (plate) are held constant at 20 degrees C and there is a constant heat source of 100 degrees C at one pre-defined point. All other…
EMiller
  • 2,669
  • 3
  • 29
  • 52
5
votes
2 answers

Unifying polykinded quantification variable with tuple kinded type

I have the following class representing categories where the object class is represented by a kind, and each hom class is represented by a type indexed by types of the aforementioned kind. {-# LANGUAGE GADTs, DataKinds, KindSignatures, PolyKinds…
Asad Saeeduddin
  • 43,250
  • 5
  • 81
  • 127
5
votes
1 answer

GeneralizedNewtypeDeriving fails for PersistFieldSql

I'm trying to define a Markdown newtype, and using GeneralizedNewtypeDeriving to automatically define new instances: import Text.Markdown import Yesod.Text.Markdown import Database.Persist.Sql newtype MarkdownNewT = MarkdownNewT { getMarkdown ::…
jcristovao
  • 554
  • 2
  • 12
1
2 3 4 5 6 7