Misha Aizatulin wrote
> I am using existential boxes like
> > data Box cxt = forall a . Sat (cxt a) => Box a
> here Sat is taken from [1]:
> > class Sat a where dict :: a
> The result is a box type which can have variable context imposed on
> its contents. What I noticed is that sometimes I
bring.
The shown GADT encoding seems to be of the kind that is convertible to
typeclasses in the straightforward way, see for example,
http://pobox.com/~oleg/ftp/Haskell/GADT-interpreter.hs
Inn this particular example, GADT do not bring any
power. Incidentally, the typeclass encoding has an
It has been already remarked that any algorithm of finding prime
numbers that uses division or `mod` operations cannot be called
(Eratosthenes) sieve. The insight of Eratosthenes is finding primes
without resorting to division or multiplication. In his time, doing
either of those operations was qu
We further simplify the previously posted genuine sieve algorithm and
generalize it to the finding of lucky numbers.
We observe that we only need to store marks _signifying_ the integers,
but never the integers themselves. Thus we arrive at the algorithm
that is distinguished from all previously
On 2/21/07, Alfonso Acosta wrote:
> In my opinion adding Type-level lambdas would be the way to go, but
> they unfortunately are not part of Haskell.
Type-level lambdas are already present in Haskell. Please see the
messages
On computable types. I. Typed lambda and type closures
http://www.has
Nicolas Frisby wrote:
> Some of the code from the previous wiki link, type-level decimal
> numbers
I would rather advice against type-level decimal numbers, if we are
looking at a lightweight solution. The [complete] code at
http://www.haskell.org/haskellwiki/Non-empty_list
is Haskell98!
Alfonso Acosta wrote:
> class Synchronous s f1 f2 | s -> f1, s -> f2 where
> mapSY :: f1 a b -> s a -> s b
> delaySY:: a -> s a -> s a
> zipWithSY :: f2 a b c-> s a -> s b -> s c
>
> The goal of this class is to extend the name of the following
> functions (which BTW ar
Perhaps you might want include in your test the following:
http://www.haskell.org/pipermail/haskell-cafe/2007-February/022437.html
It seems quite close to the genuine Eratosthenes sieve algorithm: it
employs the idea of marks, it can cross composite numbers off several
times, and it never trie
endArbitrary a b c
they are indeed the same: hence the typechecker complaint.
That said, it is quite possible in Haskell to achieve genuine
class-based dispatch, with backtracking if necessary:
http://pobox.com/~oleg/ftp/Haskell/poly2.txt
However, it seems that your particular problem
Stefan O'Rear wrote:
> Personally I like the GADT approach best since it is very flexible and
> convienient. I have never used a purpose-build computer proof system,
> but (modulo _|_) it took me less than 10 minutes to answer
> LoganCapaldo (on #haskell)'s challenge to proof that + was commutati
Steve Downey wrote:
> In the last OO design in Haskell thread (and probably in every one
> preceeding it), it was suggested that having some examples might be a good
> idea.
>
> Since most people with existing designs will have some familiarity with
> Design Patterns, and those are typical buildin
just uses the results of the analysis.
> I wasn't able to find the definition of AllOf(But):
It is in the complete code
http://pobox.com/~oleg/ftp/Haskell/poly2.hs
It isn't that interesting:
> data AllOfBut x y
{-# OPTIONS -fglasgow-exts #-}
{-# OPTIONS -fallow-
Takusen permits on-demand processing on three different levels. It is
specifically designed for database processing in bounded memory with
predictable resource utilization and no resource leaks.
But first, about getContents. It has been mentioned a while ago that
getContents should be renamed to
Simon Marlow wrote:
> Anyway, I just wanted to point out that nowadays we have the option of
> using imprecise exceptions to report errors in lazy I/O.
Is this really a solution? Currently, getContents reports no errors
but does perfect error recovery: the result of the computation prior to
the e
Neil Mitchell wrote:
> I suggest you try rewriting this program to be complete:
>
> http://darcs.haskell.org/nofib/imaginary/digits-of-e2/Main.lhs
>
> (if you do, please post the result to the list)
As Gen Zhang noted, the problem seems to be quite straightforward:
just express in types the fact
Neil Mitchell wrote:
> newtype N1 = N1 Int
> (put that in a module and don't export N1)
>
> define the constant 2, define the increment operator, change div and mod.
That is precisely what I would have done.
> Now we've mainly got a proof in the type checker, but we still don't
> actually have a
> the usual caveats about unsafePerformIO apply, so perhaps you wouldn't want
> to use this in a database library..
Indeed. This is quite problematic, from the practical point of view of
making resources difficult to control (cf. another thread of file
handle leakage), to the theoretical point th
Andrew Wagner wrote
> data Foo a = Bar a
> data (Ord a) => Baz a = Bah a
>
> Note that both of these have kind * -> *. However, Baz could never be
> an instance of monad, because there is a restriction on the types it
> can operate on.
There is a wide-spread opinion that one ought not to give con
[Please follow-up to [EMAIL PROTECTED]
S. Alexander Jacobson wrote:
> HLists require you to define Labels and basically only use label
> values that are themselves either scalar or HLists.
> ...
> With SYB you create field labels using newtype (or data) declarations
> e.g.
>
>data Salary = S
DavidA wrote:
> I'm trying to write some code which involves lots of matrix multiplications,
> but whenever I do too many, I get stack overflows (in both GHCi 6.4.2, and
> Hugs May 2006).
By placing a couple of strictness annotations, your test' gives the
expected answer (given some time) on Hugs
Nicolas Frisby wrote:
> My question is: Given products and a fixed point combinator, can any
> pure expression be transformed into a corresponding expression that
> has just a single use of fix?
Albert Y. C. Lai pointed out model-theoretical and CPU-practical
answers. There is also a Haskell-auto
Jean-Marie Gaillourdet wrote
> I am trying to do something like the following:
> > {-# OPTIONS -fglasgow-exts -fallow-undecidable-instances #-}
> > module TestCase where
> >
> > data Any root = forall pos sel . T root pos sel => ANY pos
> >
> > class T root pos sel | pos -> root, root -> sel wher
Jean-Marie Gaillourdet wrote:
>> class T root pos sel | pos -> root, root -> sel where
>>f :: pos -> sel -> Bool
>> instance T root (Any root) sel
> If that is correct, I don't understand why this instance should be to
> general, as every instantiation of "root" exactly determines the
> corres
>>> class T root pos sel | pos -> root, root -> sel where
>>>f :: pos -> sel -> Bool
>>> instance T root (Any root) sel
> But the same applies to the second functional dependency and the type
> variable sel. Every instantiation of root determines the instantiation
> of sel. And that forbids i
Alfonso Acosta wrote:
I have a type problem in my code which I dont know how to solve
> data HDSignal a = HDSignal
> class HDPrimType a where
> class PortIndex a where
>
> class SourcePort s where
> -- Plug an external signal to the port
> plugSig :: (HDPrimType a, PortIndex ix) =>ix -> s ->
Alfonso Acosta wrote:
> I tried the existential approach when it was previously suggested by
> Chris, but the problem is that, for some Source instances calling
> methods from HDPrimType within supplySig is not enough. Thus, it
> doesn't work with existentials due to their limitations.
I see. The
Ryan Dickie wrote:
> I also hate matlab to death. Is there any possibility of using haskell as a
> replacement using ghci?
Yes. The strongly typed linear algebra project (Vectro) does exactly
that. With an added guarantee that attempting to add or multiply
matrices of inappropriate sizes is a typ
Neil Mitchell wrote:
> I'm looking for a type class which checks whether two types are the
> same or not.
This problem is more complex than appears. It has been solved,
however. IncoherentInstances are not required, as IncoherentInstances
are generally unsafe.
For the full discussion of various
The examples presented so far seem to show that the computation will
eventually run in the IO monad. One may wonder then why do we need
RWST transformer, given that the IO monad can implement both the state
and writer. At the very least me need the reader transformer, which is
the least demanding
> Thanks for pointing that out. As far as I can see, this requires a new
> instance declaration for every type?
I guess it depends on how many extensions one may wish to enable. At
the very least we need multi-parameter type classes with functional
dependencies (because that's what TypeEq is in a
> > - If we permit overlapping instances extension, then a few lines of code
> > decide equality for all existing and future types:
> >
> > class TypeEq x y b | x y -> b
> > instance TypeEq x x HTrue
> > instance TypeCast HFalse b => TypeEq x y b
>
> This is exactly what I
Greg Meredith wrote:
> The file compiles with ghc as is. If you uncomment the last
> section, however, you see that to close the loop on the constraints for the
> agent syntax we hit a typing error. i think this is a hard
> constraint in Haskell that prevents this level of generality in the
> spec
> Is there documentation on the multi-parameter type classes?
Sections 7.4.2. Class declarations, 7.4.3 Functional dependencies and
7.4.4. Instance declarations of the GHC user guide give the short
description of these features. These section refer to a couple of
papers. The best explanation can
Thomas Schilling wrote:
> data T
> class Foo ns a b c | ns -> a, ns -> b, ns -> c where
> mkFoo :: ns
> defaultA :: a
> defaultB :: c -> IO b
> defaultC :: [T] -> c
> f :: c -> b -> a -> (b, Int)
> data DefaultA
> instance Foo ns a b c => Apply DefaultA ns a where
>
Ilya Tsindlekht wrote:
> Does the definition of monad silently assume that if f and f' are equal
> in the sense that they return the same value for any argument o correct
> type then m >>= f = m >>= f'
Of course NOT! Here's an example, in a State monad
f x = put True
f' x = put
Ilya Tsindlekht wrote
> > It may be useful to relate to imperative programming:
> > m1 >>= (\x -> m2)
> > is
> > let x = m1 in m2
> The analogy is not always straight-forward - try the list monad.
This equivalence holds even for the List Monad. Here is an example of
non-determinism:
> In Haskell, is it possible to declare a type constructor with a variable
> number of type variables e.g.
>
> data Tuple *
>
> allowing the following declarations:
>
> t: Tuple
> u: Tuple Bool
> v: Tuple Bool Int
> w: Tuple Bool Int Char
Although the data constructor such as the `Tuple' is
Adrian Hey wrote:
> -- Instances of GT are instances of Eq --
> instance (GT map key, Eq a) => Eq (map a) where
> map1 == map2 = assocsAscending map1 == assocsAscending map2
> ...
> Overlapping instances for Eq [(key, a)]
>arising from use of `==' at Test.hs:10:16-59
> Matching
> Also, I suspect I'm still missing something important here, for
> example I don't understand why, if it overlaps for [], it doesn't
> overlap with other instances (like Maybe for example). Or am I
> just not getting the error for Maybe because ghc stops after
> the first error?
One may think of
Philippa Cowderoy wrote:
> For example, GADTs let you implement monads as interpreters by defining a
> datatype representing the abstract syntax tree that describes a
> computation - you can't get this to type without at a minimum existential
> types and for many monad operations you need the full
Jon Harrop wrote:
> However, I can't think how you might return physically identical
> results when possible in Haskell.
Perhaps you might be interested then in the following function that
non-destructively updates a subterm in a large term, preserving
sharing. The function can be used to do a su
mingli yuan wrote:
> Seems mathematic axioms and pattern matching are different things.
> So how could I rewrite the equations to pattern matching? Which technique
> should I learn?
Haskell is more suitable for re-writing systems, which are based
on oriented equations. The question of orientation
I'm late to this discussion and must have missed the motivation for
it. Specifically, how is your goal, vector/tensor operations that are
statically assured well-dimensioned differs from general
well-dimensioned linear algebra, for which several solutions have been
already offered. For example, th
Well, I guess you might be interested in geometric algebra then
http://dl.acm.org/citation.cfm?id=1173728
because Geometric Algebra is a quite more principled way of doing
component-free calculations. See also the web page of the author
http://staff.science.uva.nl/~fontijne/
Geige
> It seems very interesting, but I have not currently the time to make a
> detailed comparison with vector/tensor algebra. Moreover I have not
I would suggest the freely available
Oersted Medal Lecture 2002
by David Hestenes
http://geocalc.clas.asu.edu/pdf/OerstedMedalLe
TP wrote:
> pr :: Name -> ExpQ
> pr n = [| putStrLn $ (nameBase n) ++ " = " ++ show $(varE n) |]
The example is indeed problematic. Let's consider a simpler one:
> foo :: Int -> ExpQ
> foo n = [|n + 1|]
The function f, when applied to an Int (some bit pattern in a machine
register), produces _c
Andreas wrote:
> The greater evil is that Haskell does not have a non-recursive let.
> This is source of many non-termination bugs, including this one here.
> let should be non-recursive by default, and for recursion we could have
> the good old "let rec".
Hear, hear! In OCaml, I can (and often
Jon Fairbairn wrote:
> It just changes forgetting to use different variable names because of
> recursion (which is currently uniform throughout the language) to
> forgetting to use non recursive let instead of let.
Let me bring to the record the message I just wrote on Haskell-cafe
http:/
> If you would like to write
>
> let (x,s) = foo 1 [] in
> let (y,s) = bar x s in
> let (z,s) = baz x y s in
>
> instead, use a state monad.
Incidentally I did write almost exactly this code once. Ironically, it
was meant as a lead-on to the State monad.
But there have been other ca
Alberto G. Corona wrote:
> I think that a non-non recursive let could be not compatible with the pure
> nature of Haskell.
I have seen this sentiment before. It is quite a mis-understanding. In
fact, the opposite is true. One may say that Haskell is not quite pure
_because_ it has recursive let.
I'd like to emphasize that there is a precedent to non-recursive let
in the world of (relatively pure) lazy functional programming.
The programming language Clean has such non-recursive let and uses
it and the shadowing extensively. They consider shadowing a virtue,
for uniquely typed data.
Richa
Here is one possible approach. First, convert the propositional
formula into the conjunctive normal form (disjunctive will work just
as well). Recall, the conjunctive normal form (CNF) is
type CNF = [Clause]
type Clause = [Literal]
data Literal = Pos PropLetter | Neg PropLetter
type PropL
ivan.chollet wrote:
> let's consider the following:
>
> let fd = Unix.open ...
> let fd = Unix.open ...
>
> At this point one file descriptor cannot be closed. Static analysis will
> have trouble catching these bugs, so do humans.
Both sentences express false propositions.
The given code, if Has
Here is a snippet from a real code that could benefit from
non-recursive let. The example is notable because it incrementally
constructs not one but two structures (both maps), ast and headers.
The maps are constructed in a bit interleaved fashion, and stuffing
them into the same State would be un
Perhaps effect libraries (there are several to choose from) could be a
better answer to Fork effects than monad transformers. One lesson from
the recent research in effects is that we should start thinking what
effect we want to achieve rather than which monad transformer to
use. Using ReaderT or
I must stress that OpenUnion1.hs described (briefly) in the paper
is only one implementation of open unions, out of many possible.
For example, I have two more implementations. A year-old version of
the code implemented open unions *WITHOUT* overlapping instances or
Typeable.
http://okmij.
> For lazy I/O, using shows in Haskell is a good analogue of using
> #printOn: in Smalltalk. The basic form is "include this as PART of
> a stream", with "convert this to a whole string" as a derived form.
>
> What the equivalent of this would be for Iteratees I don't yet
> understand.
Why not t
Evan Laforge wrote:
> I have a typeclass which is instantiated across a closed set of 3
> types. It has an ad-hoc set of methods, and I'm not too happy with
> them because being a typeclass forces them to all be defined in one
> place, breaking modularity. A sum type, of course, wouldn't have th
[I too had the problem sending this e-mail to Haskell list.
I got a reply saying the message awaits moderator approval]
Evan Laforge wrote:
> I have a typeclass which is instantiated across a closed set of 3
> types. It has an ad-hoc set of methods, and I'm not too happy with
> them because bein
> I've been toying with using Data Types a la Carte to get type
> representations, a `Typeable` class and dynamic types parameterized by a
> possibly open universe:
If the universe is potentially open, and if we don't care about
exhaustive pattern-matching check (which is one of the principal
ben
Thiago Negri wrote:
> Why type inference can't resolve this code?
> {-# LANGUAGE RankNTypes, ConstraintKinds #-}
>
> bar :: (Num a, Num b) => (forall c. Num c => c -> c) ->Either a b ->Either a b
> bar f (Left a) = Left (f a)
> bar f (Right b) = Right (f b)
>
> bar' = bar (+ 2) -- This compiles o
> Manuel M T Chakravarty:
> Hugo Pacheco:
> > I would simply like the compiler not to use that instance if the
> > equality constraint does not hold, like some another instance
> > dependency constraint, but I assume that is not possible.
>
> This is independent of type families. The selection o
Sterling Clover wrote:
> there's no standard way that I know of besides "inspection" to
> determine if code might throw an exception, and this is particularly
> the case with the dreaded lazy IO of prelude functions.
The following old message showed even two ways of doing exactly that
-- in Haske
Martin Hofmann wrote:
> Thanks a lot, this helps a bit, but access to function bodies is exactly
> what I need.
Then perhaps you might like the method of reconstructing bodies (of
possibly compiled) functions
http://okmij.org/ftp/Computation/Generative.html#diff-th
in the form of AST --
The following code solves exactly the problem of implementing
(restricted) MonadPlus in terms of Data.Set:
http://okmij.org/ftp/Haskell/DoRestrictedM.hs
The code is written to demonstrate the do-notation. We write the
monadic code as usual:
> test1s_do () = do
> x <- return "a"
> re
Eric Stansifer wrote:
> I am using a bunch of empty type classes to categorize some objects:
>
> > class FiniteSolidObject o
> > class FinitePatchObject o
> > class InfiniteSolidObject o
>
> Since "solid objects" are exactly "finite solid objects" plus
> "infinite solid objects", there is an obvio
Luke Palmer wrote in response to Harald ROTTER
> > I also wonder if there is some kind of "generalized" foldr such that, e.g.
> > D1 $ D0 $ D0 $ Sz = specialFoldr ($) Sz [D1,D0,D0]
> > I think that this foldr must be some "special" foldr that augments the data
> > type of the result in each f
I believe the original notion of type by Russell is most insightful,
bridging the semantic notion of type (type as a set of values) and the
syntactic notion (type system as a syntactic discipline, a statically
decidable restriction on terms).
That point is discussed at some length in Sec 3 (pp. 7
If I understand you correctly, the problem is to annotate an already
constructed tree with arbitrary pieces of new data -- hopefully
without reconstructing the tree. Perhaps the approach used in the
FLOLAC type-checkers would be helpful. The `tree' was an expression in
lambda-calculus to type chec
John Ky wrote:
> Is there a way to define type r to be all types except functions?
Perhaps the following article
How to write an instance for not-a-function
http://okmij.org/ftp/Haskell/typecast.html#is-function-type
answers your question. It shows several complete examples.
Martin Hofmann asked:
> Is there a Haskell implementation of the paper "Typing Dynamic Typing"
> by Baars and Swierstra
There is a different implementation but in the same spirit
http://okmij.org/ftp/tagless-final/IncopeTypecheck.hs
http://okmij.org/ftp/Computation/tagless-typed.
> Does anyone know of a trick to accomplish `typeOf id'?
> Using something else than TypeRep as the representation, of course.
Yes. The analysis of polymorphic types has been used in the inverse
type-checker
http://okmij.org/ftp/Haskell/types.html#de-typechecker
The enclosed code compute
wren ng thornton wrote:
> > how, for instance, turn a nested Map like
> >
> > Map Int (Map Int (Map String Double)
> >
> > into a "zipped" version.
> You can't. Or rather, you can't unless you have access to the
> implementation of the datastructure itself; and Data.Map doesn't provide
> enough de
> ../haskell/prepose.lhs:707:0: Parse error in pattern
> which is pointing at:
> normalize a :: M s a = M (mod a (modulus (undefined :: s)))
The code indeed used lexically scoped type variables -- which GHC at
that time implemented differently. Incidentally, on the above line,
M s a is the type a
> It opens and closes each file in turn; but it would it be
> unwise to open and close each file as we'd read a chunk from
> it? This would allow arbitrary interleaving.
If I understand you correctly, you are proposing processing several
files in parallel, so to interleave IO. If the `files
One should keep in mind the distinction between schematic variables
(which participate in unification) and universally quantified
variables. Let's look at the forall-elimination rule
G |- e : forall a. A
E
G |- e : A[a := t]
If the term e has the typ
Regions is an automatic resource management technique that statically
ensures that all allocated resources are freed and a freed resource
cannot be used. Regions also promote efficiency by helping to structure
the computation so that resources will be freed soon, and en
masse. Therefore, regions a
First of all, ListT is not a monad transformer, since it breaks the
law of associativity of bind:
*Control.Monad.List> let one = (lift $ putStrLn "1") :: ListT IO ()
*Control.Monad.List> let two = (lift $ putStrLn "2") :: ListT IO ()
*Control.Monad.List> let choice = return 1 `mplus` return 2 ::
hat file A is closed before file B is opened?
To which the user tibbe replied
> You can typically explicitly close the files as well.
and the user dobryak commented
> Regions that Oleg refers to started out with region-based memory allocation,
> which is effectively a stack allocation strate
> How do I add type annotations to interior locations in an abstract
> syntax tree?
> i.e. the type it [algorithm] infers is the type of the whole
> program, I would also like the types of any internal let-rec
> definitions so I can label my AST.
I had exactly the same problem: type reconstr
> At present we can easily express different flavors of conjunction, but
> expressing disjunction is hard.
Disjunction is not particularly difficult. See, for example,
http://okmij.org/ftp/Haskell/TTypeable/TTypeable.hs
and search for ORELSE. The code demonstrates higher-order type-lev
Alberto G. Corona wrote about a monad to set a checkpoint and be able
to repeatedly go to that checkpoint and re-execute the computations
following the checkpoint.
http://haskell-web.blogspot.com.es/2012/03/failback-monad.html
The typical example is as follows.
> test= runBackT $ do
>l
> I thoutgh on the use or ErrorT or something similar but the fact is
> that i need many bacPoints, not just one. That is, The user can go
> many pages back in the navigation pressing many times te back
> buttton.
The approach in the previous message extends to an arbitrary,
statically unknown nu
Ben wrote:
> - use Data.Unique to identify Refs, and use existential quantification
> or Data.Dynamic to create a heterogenous Map from uid to log. for
> example, to represent a log of compare-and-swaps we might do something
> like
> data Ref a = Ref (IORef a) Unique
> data OpaqueCAS = forall a
> | instance (Table a c, Show c) => Show a where
> I would have thought that there is on overlap: the instance in my code
> above defines how to show a table if the cell is showable;
No, the instance defines how to show values of any type; that type
must be an instance of Table. There is no `if'
Victor Miller wrote:
> I was writing a Haskell program which builds a large labeled binary tree
> and then does some processing of it, which is fold-like. In the actual
> application that I have in mind the tree will be *huge*. If the whole tree
> is kept in memory it would probably take up 100'
> i think what i will do is to instantiate all table types individually:
> | instance Show c => Show (SimpleTable c) where
> | showsPrec p t = showParen (p > 10) $ showString "FastTable " .
> | shows (toLists t)
I was going to propose this solution, as we
Yves Pare`s wrote:
> So I'm trying to make a type level function to test if a type list contains
> a type. Unless I'm wrong, that calls to the use of a type family.
More crucially, list membership also calls for an equality
predicate. Recall, List.elem has the Eq constraint; so the type-level
mem
Nicolas Trangez wrote
> The protocol I'd like to implement is different: it's long-running using
> repeated requests & responses on a single client connection. Basically,
> a client connects and sends some data to the server (where the length of
> this data is encoded in the header). Now the serv
Kangyuan Niu wrote:
> Aren't both Haskell and SML translatable into System F, from which
> type-lambda is directly taken?
The fact that both Haskell and SML are translatable to System F does
not imply that Haskell and SML are just as expressive as System
F. Although SML (and now OCaml) does have
> Do you know why they switched over in GHC 6.6?
If I were to speculate, I'd say it is related to GADTs. Before GADTs,
we can keep conflating quantified type variables with schematic type
variables. GADTs seem to force us to make the distinction.
Consider this code:
data G a where
GI :: Int
> And yes to first order predicate calculus too!
Just two weeks ago Chung-chieh Shan and I were explaining at NASSLLI
the embedding in Haskell of the higher-order predicate logic with two
base types (so-called Ty2). The embedding supports type-safe
simplification of formulas (which was really nee
Tillmann Rendel has correctly noted that the source of the problem is
the correlation among the random variables. Specifically, our
measurement of Sun's mass and of Mars mass used the same rather than
independently drawn samples of the Earth mass. Sharing (which
supports what Functional-Logic prog
The bad news is that indeed you don't seem to be able to do what you
want. The good news: yes, you can. The enclosed code does exactly what
you wanted:
> sunPerMars :: NonDet Double
> sunPerMars = (/) <$> sunMass <*> marsMass
>
> sunPerMars_run = runShare sunPerMars
> sunPerMars_run_len = length
>1. Haskell's type inference is NON-COMPOSITIONAL!
Yes, it is -- and there are many examples of it. Here is an example
which has nothing to do with MonomorphismRestriction or numeric
literals
{-# LANGUAGE ExtendedDefaultRules #-}
class C a where
m :: a -> Int
instance C () where
m
> http://en.pk.paraiso-lang.org/Haskell/Monad-Gaussian
> What do you think? Will this be a good approach or bad?
I don't think it is a Monad (or even restricted monad, see
below). Suppose G a is a `Gaussian' monad and n :: G Double is a
random number with the Gaussian (Normal distribution). Then
> > Exercise: how does the approach in the code relate to the approaches
> > to sharing explained in
> > http://okmij.org/ftp/tagless-final/sharing/sharing.html
> >
> Chapter 3 introduces an implicit impure counter, and Chapter 4 uses a
> database that is passed around.
> let_ in Chapter
> However, if your are using ExtendedDefaultRules then you are likely to
> know you are leaving the clean sound world of type inference.
First of all, ExtendedDefaultRules is enabled by default in
GHCi. Second, my example will work without ExtendedDefaultRules, in
pure Haskell98. It is even shor
Ryan Ingram wrote:
> I've been seeing this pattern in a surprising number of instance
> definitions lately:
>
> instance (a ~ ar, b ~ br) => Mcomp a ar b br [1]
> instance (b ~ c, CanFilterFunc b a) => CanFilter (b -> c) a [2]
And here are a few more earlier instances of the same occurrence:
> did you see this, and the discussion around that time?
> http://www.haskell.org/pipermail/haskell-prime/2012-May/003688.html
>
> I implemented hDeleteMany without FunDeps -- and it works in Hugs (using
> TypeCast -- but looks prettier in GHC with equality constraints).
I'm afraid I didn't see
101 - 200 of 429 matches
Mail list logo