anatoli anatoli at yahoo wrote:
Attached are two interpreters: one for untyped lambda calculus,
I'm afraid the attached interpreter can't be an implementation of the
lambda calculus. For one thing, it lacks the hygiene of substitutions:
Lambda :t lambdaEval (A (L X (L Y (A X Y))) T)
(with the regression tests)
can be found at
http://pobox.com/~oleg/ftp/Computation/rewriting-rule-lambda.txt
The calculator is implemented in CPS, in some sort of extended lambda
calculus. Therefore, the code has three kinds of lambdas: of the source
language, of the transformer meta
Hello!
Hal Daume III wrote:
[description of a parsing problem that involves forward references]
Forward references is the problem. To properly solve it, you have to
find a fixpoint. The best way to avoid hitting the bottom is to make
sure that the fixpoint combinator is applied to a function.
(lambda-calculator) are the same;
therefore, the parser can indeed apply itself.
The evaluator's source code:
http://pobox.com/~oleg/ftp/Haskell/Lambda_calc.lhs
explains the algorithm in detail. The file has five times more lines
of comments than lines of code. The file also expounds upon
Dimitre Novatchev wrote on May 4, 2002:
In his excellent book Simon Thompson defines scaling of the elements of
a sequence of random numbers from the interval [0, 65535] to an
interval [s,t] in the following way (top of page 368):
scaleSequence :: Int - Int - [Int] - [Int]
scaleSequence
This message derives an integer interval mapping function that is not
only provably within the given range but also uniform. This is the
function to use when mapping random integers from one interval to a
smaller one.
Problem: given an integer n within [0..maxn], design a scaling
function sc(n)
There is another solution to the problem of configurational
parameters. The main part of the solution is portable, does not depend
on any pragmas, does not use unsafe operations, does not use implicit
parameters, and does not require any modifications to the user code. I
must warn that it is
.
An example code [2] demonstrates parsing and unparsing of a
namespace-rich document: a DAML RDF file. DAML (DARPA Agent Markup
Language) ontologies typically use a great number of namespaces. The
example code demonstrates that
parse . unparse . parse === parse
[1] http://pobox.com/~oleg/ftp
Hello!
Simon Peyton-Jones wrote:
class C a b | a - b where {}
instance C Int Int where {}
f1 :: (forall b. (C Int b) = Int - b)
f1 x = undefined
Indeed, this gives an error message
Cannot unify the type-signature variable `b' with the type `Int'
Expected type: Int
Hello!
It seems we can truly implement Monad2 without pushing the
envelope too far. The solution and a few tests are given below. In
contrast to the previous approach, here we lift the type variables
rather than bury them. The principle is to bring the type logic
programming at the level
| The reason, which is thoroughly explained in Simon Peyton-Jones'
| message, is that the given type signature is wrong: it should read
| f1 :: (exists b. (C Int b) = Int - b)
Can you give an example of its use?
Yes, I can.
class (Show a, Show b) = C a b | a - b where
doit:: a -
The following is a more flexible alternative to overloading. We
essentially define a function on types and invoke it, seemingly at run
time. No Dynamics or unsafe computations are employed. We only need
existential types, multi-parameter classes and functional
dependencies. The code also shows
Ashley Yakeley wrote:
If this were allowed, it would effectively allow type-lambda
class C a b | a - b
instance C Int Bool
instance C Bool Char
newtype T a = MkT (forall b.(C a b) = b)
helperIn :: (forall b.(C a b) = b) - T a
helperIn b = MkT b; -- currently won't work
helperOut :: T a
= Manager: ++ (show x)
Thanks
Oleg
___
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell
Hello!
Example: I wish to define a structured container type, let's call it a
RatsNest, that is type-variable in two ways:
(a) it is parameterized by a type of some class, let's call it RatsTail,
such that a RatsNest is a structure of things that have common
properties. Certain
Hello!
I wasn't aware there was a standard design,
Edison is a good standard (in particular, Collection.hs, found, for
example, in /usr/local/share/hugs/lib/exts/).
The following projects have a lot of helpful code:
http://sourceforge.net/projects/hbase/
John Hughes wrote:
I didn't find this when I needed to lock files, so my solution (under
Unix) was to write a little C code and call it via the FFI. I used a
single lock file, since my application was a CGI script which runs fairly
rarely -- there's no need for a finer grain of locking.
Many
i'm hoping to be able to simulate a sort of dynamic dispatch based on
class instances.
It seems you want to dispatch based not on a type but on the
constraint of a type.
You code almost worked. Here's the a bit updated and working version.
class Foo a where { foo :: a - Bool }
class Bar a
Hello!
The paper
http://research.microsoft.com/~simonpj/papers/hmap/
by Ralf Laemmel and Simon Peyton Jones gave a reference
implementation of a 'cast' function. Here's another implementation:
cast:: (Show a, Read b) = a - Maybe b
cast = read_as . show
where
read_as s =
Tomasz Zielonka wrote:
I don't know how it works in Python, but in perl the code in eval is
executed in current lexical scope.
Eval of the kind
let x = 1 in eval x
is plainly an abomination. Such an eval all but precludes compilation
because the compiler is not free to alpha-rename
Back in September 2001, Koen Claessen wrote:
] Here is a little experiment I did a while ago. I was trying to isolate
] the capability of the ST monad to deal with different types at the
] same time I conjecture this functionality cannot be implemented
] in Haskell 98, nor in any of the
Heaps should be more dynamic than this; the (type of the) *reference*
should encode the type it points to, but the (type of the) *heap*
should not.
However, the heap can store polymorphic values. Therefore, we can use
a heap to store the polymorphic heap... Your example, slightly
re-written
update :: (Typable b) = FM k - Key k a - b - (FM ...)
I didn't know constraints on values are allowed... Given below is the
implementation of the required interface, in Haskell98
module TypedFM where
data FM k -- Abstract; finite map indexed bykeys of type k
data Key k
So what does the function
insert2 val1 val2 =
let
(m1,k1) = insert empty (Just val1)
(m2,k2) = insert m1 (Just val2)
m3 = update m2 k1 Nothing
in
isJust (lookup m3 k2)
return? It looks to me as if it returns True if val1 and val2
Ed Komp replied to Simon Peyton-Jones:
Within the GHC compiler
can't be instantiated to Double --- but that's tricky to pin down.
this may be tricky to pin down.
But, there is specific information in my example to exclude Double:
I had carefully constructed the type definitions to avoid
an advanced application of mcomp, to
point-free programming (categorical products).
[1] http://pobox.com/~oleg/ftp/Haskell/types.html
The following code, excerpted from [1], was used for the above
examples. -fglasgow-exts are needed.
class MCompose f2 cp gresult result | f2 cp gresult - result, f2-cp
This message shows how to map _types_ to integers at compile time --
and then extend this facility to run-time so it can be used with
existentially-quantified types. It is statically guaranteed that
different types receive different integer labels. Unlike TyCons of
Dynamics, our mapping does NOT
This message describes functions safeCast and sAFECoerce implemented
in Haskell98 with common, pure extensions. The functions can be used
to 'escape' from or to existential quantification and to make
existentially-quantified datatypes far easier to deal with. Unlike
Dynamic, the present approach
This is a Related Work section of the previous message. We compare
three main methods of achieving safe casts. It seems that the method
proposed in the earlier message is quite different -- especially in
terms of extensibility. In this message, we compare the extensibility
of four techniques.
Does this technique extend to polymophic types?
Yes, of course. The type F a b in the earlier message was polymorphic.
Let's say we have the following type:
data D a = C | D a
Is it possible to index the type D a?
I have just lifted the polymorphic Maybe -- which is isomorphic to
your
This message illustrates how safe casting with multiple universes can
be extended to new user-defined, polymorphic datatypes. We show a
_portable_ mapping of polymorphic types to integers. Different
instances of a polymorphic type map to different integers. Phantom
types can be either disregarded
I defined type recursion and naturals as
newtype Mu f = In {unIn :: f (Mu f)}
data N f = S f | Z
type Nat = Mu N
An application of Mu should be showable if the functor maps showable types
to showable types, so the most natural way to define the instance seemed
to be
instance (Show a =
Wolfgang Jeltsch has observed:
I have this code:
class C a b c | a b - c where
f :: a - b - c
instance C a b c = C a (x,y,b) c where
f a (_,_,b) = f a b
instance C a (a,c,b) c where
f _ (_,c,_) = c
ghci -fglasgow-exts -fallow-overlapping-instances
You might also wish to look at the typed heaps, which have been
discussed here on many occasions. Given the constant piece of code in
the appendix (which does *not* depend on user types and can be put
into a separate, constant module) you can write
data Gender = Masc | Fem | Neutr deriving
There is no need for Maybe. In fact, if you attempt to fetch
a type that you didn't put into the attrs, you get a _compile-time_
error.
But I'm not sure if it's suitable for what I'm doing, as the attributes
get inserted at run time, and not all of them appear everywhere. So
Maybe is
Steffen Mazanek posed a problem: given the monad:
data Error a = Error String | Ok a
data TI a = TI (Subst - Int - Error (Subst, Int, a))
instance Monad TI where
return x = TI (\s n - Ok (s,n,x))
TI f = g = TI (\s n - case f s n of
Ok (s',m,x) - let TI gx = g
Hello!
Would it be possible to write a piece of Haskell code which checks
the monadic laws automatically by simulating evaluation in this way?
To some extent, yes. The proof in the previous message was based on
normalization, with respect to associative laws and some betas. So we
can take
Ashley Yakeley wrote:
Would it be reasonable for the compiler to check back through the
stack and allow the circularity? It will just create an ordinary
recursive function.
The following works.
Flags: -fglasgow-exts -fallow-undecidable-instances
data D r = ZeroD | SuccD (r (D r))
lists and losing the
capability of ensuring I am manipulating lists of the same length.
Perhaps you might find the following
http://pobox.com/~oleg/ftp/Haskell/number-parameterized-types.html
relevant to your task. The page demonstrates bitvectors of a
statically-checked width
of hfold_left'. OTH, myopen
captures the continuation of hfold_left' in an IO action. This
relationship once again illustrates that call/cc and Y are indeed two
sides of the same coin [3].
[1] General ways to traverse collections
http://pobox.com/~oleg/ftp/Scheme/enumerators-callcc.html
[2
Dean Herington wrote:
Can someone explain why the following doesn't work?
{-# OPTIONS -fglasgow-exts #-}
class R r where
rId :: r - String
class (R r) = RT r t where
rtId :: r - t - String
data RPair r1 r2 = RPair r1 r2
instance (R r1, R r2) = R (RPair r1 r2) where
rId (RPair
I found a case where I really need:
f :: Float - Float
where
f x is the least y such that x y
This seems to be the problem of finding the unnormalized epsilon:
the smallest positive number one can meaningfully add to the given
number x. If that x is 1.0, we're talking about the epsilon.
The problem:
liftTup f (a, b) = (f a, f b)
of the signature
liftTup:: ?? - (a,b) - (c,d)
Again, it is possible to write this in Haskell with common extensions
{-# OPTIONS -fglasgow-exts #-}
import Data.Dynamic
import Data.Maybe
liftp f (a,b) = ((fromJust . fromDynamic . f .
Hal Daume wrote:
is there a function, related to getProgName, which returns the (absolute)
path to the current program?
basically, i want to be able to read a file which i know will be in the
same directory as the current program, but not necessarily in the same
directory that we're running
Can mfix be considered as just a fix point combinator, without
any trace of effect?
The recent discussion about continuations and implementations of
Scheme in Haskell highlighted that question. The point of the
discussion is the difference between letrec implemented using the
fixpoint
There appears to be a problem with GHC's handling of multi-parameter
constraints with functional dependencies in the context of rank-2
types. The problem is not present in Hugs.
Let us first consider a simple example:
module Test where
class Foo a
class Bar a
data Obj = Obj
instance Bar
John Tromp wrote:
instance (Bar a) = Foo a
I have tried to write code myself like in the last line,
stating that any instance of one class should also be
an instance of another class. But Hugs would complain about
it.
You're right. Hugs needs to be told that the code is in an extended
I'm sorry to open an old wound. I've just had an insight for
a clarification.
On Nov 26, 2003 Ken Shan wrote:
Consider the following code, which uses type classes with functional
dependencies:
{-# OPTIONS -fglasgow-exts #-}
module Foo where
class R a b | a - b where r :: a - b
Hello!
So, how can you come up with a type class which provides a polymorphic
'add' function, considering you don't even know how many parameters
each data type's individual add function uses?
Very easily: every Haskell function takes only one
argument. Always. Ever.
For example, say I'm
Hello!
If indeed the read performance is at premium and updates are
infrequent, by bother with ternary etc. trees -- why not to use just a
single, one-level array. Given a reasonable hash function, the
retrieval performance is O(1). And still, no IO/ST are necessary.
{-# OPTIONS
Simon Peyton-Jones wrote:
In Haskell today, you can at least tell what value is bound to each
identifier in the program, *without* first doing type checking.
I'm afraid I'm confused. In the following code
data Z
data S a
class Card c where c2int:: c - Int
instance Card Z where c2int _
[BTW, should we move to Haskell-Cafe?]
Because updates are not so infrequent that I want to pay the cost of
replicating the entire array every update (or every ten!). I'm
willing to exchange *some* read time for faster update. Also, because
small array copies may be sufficiently faster than
The code is currently like this:
instance Sig Def where
getName (DefClass c) = getName c
getName(DefProtocol p) getName p
getName(DefSignature s) = getName s
getParents(DefClass c) = getParents c
getParents(DefProtocol p) = getParents p
blah blah blah...
But this seems very
Ben Yu wrote:
The instance declaration is like this:
instance FwdSig Native
instance FwdSig Def
instance FwdSig d = Sig d
instance Sig XXX
Neither Native nor Def are direct instances of Sig.
And this XXX, it is an instance of Sig, not a FwdSig.
As you can see, there's no real
data Showable = forall a. Show a = Showable a
writer :: Chan Showable - IO ()
writer ch = mapM_ (writeChan ch) [Showable 42, Showable pi, Showable
hello, Showable 'c']
printer :: Chan Showable - IO ()
printer ch = getChanContents ch = mapM_ (\(Showable a) - print a)
However, this
Another question about overloading with type classes. It seems that these
overloaded functions cannot be passed as higher-order function. Is that
true? A higher order function can never be overloaded?
In an example, how can I pass build as a function to another function
that does some
I'm sorry I couldn't resist another example -- which requires fewer
signatures. It also illustrates storing build in data structures.
In the example below (which works with the code posted earlier) build
is used to build itself. It really has quite a few faces...
data W = W (forall r a.
Ben Yu wrote:
I'm new to haskell, new to this group, don't even know what this
cafe refers to. Is there a special place for discussing further
details?
Yes, http://haskell.org/mailman/listinfo/haskell-cafe
Similarly, a builder can be built for binary functions like addToFM.
Here's a bit
The two-class trick helps us indirectly write desirable
multi-parameter classes with functional dependencies or
overlapping. The example below happens to have both. The example
illustrates that an attempt to write desired instances directly runs
into problems of bad overlapping or violations of
The guts of the question is: can one use the class system to code up
the reflexive, transitive closure
Computing the transitive closure of types is possible:
http://www.haskell.org/pipermail/haskell-cafe/2003-October/005249.html
S. Alexander Jacobson wrote:
Also, is there a way to get the typesystem to
tell you which functions may fail i.e. which
functions have failMsg as an implicit parameter?
Generally speaking, that is not that easy. If we have a functional
composition (foo . bar), we wish its
Ben Yu wrote:
class Rule r u u' m where
apply :: r - u - m u'
data And = And
data Bin a b o = Bin a b o
instance (Monad m, Rule r1 u u' m, Rule r2 u' u'' m) =
Rule (Bin r1 r2 And) u u'' m where
apply (Bin r1 r2 _) u = apply r1 u = apply r2
Ghc complains about Could not
There is a view that in order to gain static assurances such as an
array index being always in range or tail being applied to a
non-empty list, we must give up on something significant: on data
structures such as arrays (to be replaced with nested tuples), on
general recursion, on annotation-free
the link to
the code:
http://pobox.com/~oleg/ftp/Haskell/number-param-vector-code.tar.gz
I should emphasize that all proper examples use genuine Haskell arrays
rather than nested tuples. Yet the type of the array includes its
size, conveniently expressed in decimal notation. One can specify
Hello!
Bjorn Lisper wrote:
What is the relation to the sized types by Lars Pareto and John Hughes?
It is orthogonal and complementary, as the message in response to
Conor T. McBride indicated.
What is the relation to classical range analyses for (e.g.) array index
expressions, which have
We show the Haskell implementation of keyword arguments, which goes
well beyond records (e.g., in permitting the re-use of
labels). Keyword arguments indeed look just like regular, positional
arguments. However, keyword arguments may appear in any
order. Furthermore, one may associate defaults
Martin Sulzmann stated the goal of the append exercise as follows:
] Each list carries now some information about its length.
] The type annotation states that the sum of the output list
] is the sum of the two input lists.
I'd like to give a Haskell implementation of such an append
function,
ML is known for its sophisticated, higher-order module system, which
is formalized in Dreyer-Crary-Harper language. A few months ago Ken
Shan showed a complete translation of that language into System Fw:
http://www.eecs.harvard.edu/~ccshan/xlate/
Ken Shan has concluded that languages
Dominic Steinitz wrote:
Did you get the first solution to work? When I tried it with hugs -98 I got
Yes, in the process discovering some interesting behavior of
Hugs. Here's the complete code that works with Hugs
module Foo where
class Bits a
instance (Ord a, Bits a, Bounded a, Integral
Jules Bean wrote:
Unfortunately, it's not going to work. It's not going to work because
some of the procedures take callbacks, and the callbacks are values of
type IO (). I can see two solutions to this:
a) revert to using an IORef, and use lexical scoping to define my
callbacks in a
Jo'n Fairbairn wrote:
The idea is simply that we should provide a mechanism of
saying to a compiler this file (of data) is a module that
exports only the variable v. ...
So we tell the compilation system that file
/somewhere/contains-v contains the value of the variable
v::String, and that
-archive.com/[EMAIL PROTECTED]/msg05186.html
Incidently, some of that is already available in Haskell,
http://pobox.com/~oleg/ftp/Haskell/types.html#partial-sigs
___
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell
It is well known that type classes in Haskell are open. A user may at
any time extend a visible type class by providing a new
instance. There are situations where such an extensibility is
undesirable. We may want to prevent the user from adding an instance
to our class for some specific type --
Jared Warren wrote:
I'm doing some work with heterogeneous sets as provided by the HList
library http://homepages.cwi.nl/~ralf/HList/. My code uses
projections of sets internally and I keep running into the open-world
assumption when I ask the type checker to infer the result of
projections.
Jacques Carette wrote on LtU on Wed, 11/24/2004
] One quick (cryptic) example: the same difficulties in being able to
] express partial evaluation in a typed setting occurs in a CAS
] [computer algebra system]. Of course I mean to have a partial
] evaluator written in a language X for language
Andrew Bromage wrote:
module FD where
class C from to | from - to where
g :: from - to
h :: to - from
instance C Char Bool where
g c = c == 'T'
h b = if b then 'T' else 'F'
--f :: (C Char a) = Char - a
f c = g c
Indeed, functional dependencies are the way to
Simon Peyton-Jones wrote:
|[ data MyVec a where
|[ MkMyVec :: (Foo a) = a - MyVec a
f x = case x of
MkMyVec x - rhs
constraints are always solved *lazily* when inferring, so we'd infer
f :: Foo [a] = MyVec a - ...
even without any overlap
I have been thinking about using Haskell (extended with
higher ranked polymorphism) to demonstrate to my colleagues
some ideas in second-order lambda calculus. It turned out,
however, I am puzzled by the type system myself. So I've
written to seek for help. :)
I started with define Church
in our case)
http://pobox.com/~oleg/ftp/Haskell/types.html#partial-sigs
But mainly, if we wish to hide some details of the representation, why
not to use tools that are built for that, such as applicative
functors? They are _easily_ implementable in Haskell, arguably
idiomatic, and free from
This message presents polymorphic functions that derive a term for a
given type -- for a class of fully polymorphic functions: proper and
improper combinators. This is better understood on an example:
rtest4 f g = rr (undefined::(b - c) - (a - b) - a - c) HNil f g
*HC rtest4 (:[]) Just 'x'
This is the first part of a reply to a query about a zipper with two
foci, posted on this list by Oktaviandi Hadi Nugraha on Apr 13. In
this part we introduce the framework to answer the question.
Our treatment of zipper is quite different from that of Huet (JFP,
1997) and Hinze and Jeuring (JFP
In this part about zippers with two holes, we discuss the relationship
between zippers and (database) transactions of various isolation
modes. We show the updating enumerator and the corresponding zipper
that maximally preserve sharing and can walk terms with directed
loops. We demonstrate that a
: success, failure -- but no cut
continuation. Still, control logical operations are supported. The
continuation-passing implementation was indeed difficult to find,
although the result is deceptively simple.
The code is freely available under the MIT license:
http://pobox.com/~oleg/ftp/packages
on Jun 22 Andrew Bromage wrote about the usefulness of
soft-cuts and don't care non-determinism in non-deterministic
computations in Haskell.
http://www.haskell.org/pipermail/haskell/2005-June/016037.html
Thank you very much for your explanation, it was helpful indeed. You
noted,
Some of the
Benjamin Franksen wrote:
On Thursday 25 August 2005 19:58, Udo Stenzel wrote:
[...] you'll need a type signature somewhere to help ghc resolve
the overloading of newArray and readArray, which is surprisingly
tricky due to the s that must not escape. This works:
compute :: Int - Int
We show how to merge two folds into another fold
`elementwise'. Furthermore, we present a library of (potentially
infinite) ``lists'' represented as folds (aka streams, aka
success-failure-continuation--based generators). Whereas the standard
Prelude functions such as |map| and |take| transform
Correction:
We show how to merge two folds into another fold `elementwise'. ... We
need recursive types -- but again, never value recursion.
There is no need for recursive types, actually. Higher-rank types are
still present, which we need for fold anyway. Introducing recursive
types wasn't a
/~oleg/ftp/Computation/Continuations.html#cdr-fstream
especially the reference therein:
Corrado Boehm and Alessandro Berarducci: Automatic Synthesis of Typed
Lambda-Programs on Term Algebras
___
Haskell mailing list
Just to add one more example to Ralf's reply:
We get exactly the same kind of problem if we try
*Main null [fromEnum]
interactive:1:6:
Ambiguous type variable `a' in the constraint:
`Enum a' arising from use of `fromEnum' at interactive:1:6-13
Probable fix: add a type
Hello!
I'm sure you're aware of the close connection between your FR
stuff (nice) and the foldr/build list-fusion work?
I am now. Indeed, the 'FR' representation of lists is what one passes
to 'build'. Incidentally, the higher-rank type of FR is a
_requirement_ (otherwise, things won't type)
Paul Govereau wrote:
BTW, The above program is a translation of an idiomatic use of
functors in ML (pardon my syntax):
module A : sig type t = ... end
module B : funsig(X:SHOW where t = A.t) sig bar : A.t - string end
module C : SHOW where t = A.t
open A
open B(C)
ML modules
Louis-Julien Guillemette wrote:
Say we are using a GADT to represent a simple language of boolean
constants and conditionals,
data Term a where
B:: Bool - Term Bool
Cnd :: Term Bool - Term t - Term t - Term t
and we would like to perform a type-safe CPS conversion over this
Let us consider the following simple code
{-# OPTIONS -fglasgow-exts #-}
module Foo where
data Term a where
B:: Bool - Term Bool
C:: Term Bool - Term t - Term t
I:: Int - Term Int
shw (I t) = (I ++) . shows t
shw (B t) = (B ++) . shows t
shw (C p q) = (Cnd ++) .
Stefan Monnier wrote:
instance CpsForm t t where
This can't be right, can it?
In general no: the CPS of a function certainly doesn't fit the above
pattern. So, if the source language has abstractions (the language in
the original message didn't), we have to add another instance for
CpsForm.
The evaluator of the logic
system is complete: if there is a solution, the evaluator
will always find it in finite time.
Is it also terminating? So if there is no solution it will tell you so.
The evaluator used in the yesterday's message -- no. It is merely
complete; if no solution
[Sorry for possible duplication, our DNS server seems to be broken,
and the sysadm is on vacation]
I don't think that is the problem with GADTs. The following works
untype :: Term f a - Term Untyped ()
untype (Lit x) = Lit x
untype (Succ t) = Succ (untype t)
untype (IsZero t) =
Tomasz Zielonka wrote:
I tried to implement another function:
mapChildren :: (forall a. Term f a - Term f a) - Term f b - Term f b
mapChildren fun t@(Lit x) = t
mapChildren fun (IsZero t) = IsZero (fun t)
mapChildren fun (Succ t) = Succ (fun t)
mapChildren fun (If c t e) = If
Tomasz Zielonka wrote:
The papers on GADTs have an example showing how you can transform,
traverse and evaluate ASTs (or terms) with more type safety. I've
used such an approach in one of my applications and it works remarkably
well.
However, I would like to be able to turn off that
David Roundy wrote:
The only solution I can imagine
would be to implement a class for each field name. i.e. the only reasonble
type of f I can imagine is something like
f :: Integral i, RecordHasField_foo i r = r - r
But that's a very complicated solution, and once one implemented that
Joel Reymont wrote:
How does pattern matching work with HList?
I would like to pass a HList to a function and only match if a
certain field had a certain value.
The code below defines the function foo that accepts a record and
yields one value if the field PtX of the record has the value 0.
1 - 100 of 588 matches
Mail list logo