Generalized algebraic data types, GADTs, are a more powerful form of algebraic data types that support custom constructor types.
Questions tagged [gadt]
397 questions
0
votes
3 answers
return type of GADT evaluator
I'm a bit at a loss as to why the last pattern in prodV in the following doesn't work:
{-# LANGUAGE GADTs #-}
data V a where
V0 :: Float -> V Float
Vn :: [Float] -> V [Float]
prodV :: (Num a) => V a -> V a -> a
prodV (V0 x) (V0 y) = x * y
--…

ocramz
- 816
- 6
- 18
0
votes
3 answers
Can't properly define transformation from universal type, that defined with GADT
I've defined an universal data type that can contain anything (well, with current implementation not totally anything)!
Here it is (complete code):
{-#LANGUAGE NoMonomorphismRestriction#-}
{-#LANGUAGE GADTs#-}
{-#LANGUAGE StandaloneDeriving#-}
data…

Anon Imous
- 415
- 2
- 11
0
votes
2 answers
How do I restrict the types in a heterogenous list?
I am currently trying to create a (sort of) typesafe xml like syntax embedded into Haskell. In the end I am hoping to achieve something like this:
tree = group [arg1 "str", arg2 42]
[item [foo, bar] []
,item [foo, bar] []
…

fho
- 6,787
- 26
- 71
0
votes
2 answers
haskell GADTs constructor
I have the following
data Expr = Condition v
| And Expr Expr
| Or Expr Expr
and I am asked to consider the follow untyped version in order to complete:
data Expr e where
I'm not sure what I'm suppose to write for the…

SNpn
- 2,157
- 8
- 36
- 53
0
votes
1 answer
Check whether formula is correct in haskell
---- update 2 ----
At last, he told me that is Exists…
thank you all.
---- update ----
Okay, we call it Forsome
ex3: forsome x0::[False,True]. forsome x1::[0,1,2]. (x0 || (0 < x1))
(whom told me "what is forall" added):
the constructor says "forall…

Pikaurd
- 1,114
- 1
- 8
- 22
-1
votes
1 answer
Constraining types in GADT constructor
I've a simple ADT
data Concept a = Entity a | Role a | Relation a | Resource a | Sub (Concept a)
Now I want to create a GADT using this ADT that will constrain the type signature of it's constructors. This code won't work but I want to do…

kaychaks
- 1,715
- 3
- 21
- 28
-1
votes
1 answer
OCaml Abstract typed functions
I want to accomplish something like this, but I can't quite get the syntax down.
type _ s = Var : 'a -> 'a s
type _ t =
| AA :('a -> 'a s) -> 'c t
| AB : ('a -> 'b s) -> 'c t
let apply_to x = function
| AA g -> g x
| AB g -> g x

Jeremy Rubin
- 567
- 1
- 7
- 13