Re: [Haskell-cafe] type-level integers, type-level operators, and most specific overlapping instance

2013-09-22 Thread TP
TP wrote: But I have still a question: is the behavior of GHC correct in the example of my initial post? See here: http://www.haskell.org/ghc/docs/7.6.3/html/users_guide/type-class-extensions.html#instance-overlap When matching, GHC takes no account of the context of the instance

Re: [Haskell-cafe] type-level integers, type-level operators, and most specific overlapping instance

2013-09-22 Thread TP
definition (which is indeed the definition in the Haskell report). Thanks in advance, TP ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

[Haskell-cafe] using default declaration for overloaded numeric operations

2013-09-21 Thread TP
Thanks in advance, TP ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

[Haskell-cafe] type-level integers, type-level operators, and most specific overlapping instance

2013-09-21 Thread TP
In an equation for `a': a = s * s In the expression: do { let s = ...; let a = s * s; print a } Thanks in advance, TP ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo

Re: [Haskell-cafe] type-level integers, type-level operators, and most specific overlapping instance

2013-09-21 Thread TP
context? Is it OK, or is it a deficiency? Thanks, TP - {-# LANGUAGE DataKinds #-} {-# LANGUAGE KindSignatures #-} {-# LANGUAGE StandaloneDeriving #-} {-# LANGUAGE GADTs #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE FunctionalDependencies #-} {-# LANGUAGE

Re: [Haskell-cafe] Template Haskell: let statement in a splice put in the main = do part of a program?

2013-08-27 Thread TP
and ExpQ's in a separate module. Tonight, I've tried hard one more time without more success. Maybe I have to stick to non-let expressions in the main part of a script, when it comes to TH. It should nevertheless allow me to call functions, make tests, etc. Thanks, TP

Re: [Haskell-cafe] reasons why Template Haskell does not propose something similar to Python exec() or eval()

2013-08-25 Thread TP
[Language.Haskell.TH.Syntax.Dec] -- Defined in `Language.Haskell.Meta.Parse' :i parseExp parseExp :: String - Either String Language.Haskell.TH.Syntax.Exp -- Defined in `Language.Haskell.Meta.Parse' Thanks, TP ___ Haskell-Cafe

[Haskell-cafe] reasons why Template Haskell does not propose something similar to Python exec() or eval()

2013-08-24 Thread TP
. Could you help me? Thanks in advance, TP PS: the complete Haskell example: --- module MakeVard where import Language.Haskell.TH makeVard :: Monad m = String - m [Dec] -- Equivalent to %s = \%s\ makeVard s = return [ ValD (VarP $ mkName s) (NormalB $ LitE

[Haskell-cafe] Template Haskell: let statement in a splice put in the main = do part of a program?

2013-08-24 Thread TP
, and compE is to construct list comprehensions, which is a different thing. So, is there any solution to my problem? Thanks in advance, TP ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: [Haskell-cafe] Template Haskell: let statement in a splice put in the main = do part of a program?

2013-08-24 Thread TP
fragment from the error message. Yes, I have explained why: to be able to see the evaluation of the splice; otherwise I obtain Not in scope: `a' if I uncomment -- print a at the end of my code; I have explained everything in my initial post. TP

[Haskell-cafe] typeclass constraints

2013-08-23 Thread TP
|] it works correctly. Why GHC is able to infer the typeclass constraint (Num a) in 1/, but not (Lift a) in 2/? Thanks in advance, TP ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell

Re: [Haskell-cafe] typeclass constraints

2013-08-23 Thread TP
Adam Gundry wrote: If you leave off the type signature, as you did for sum', the right thing will be inferred. Thanks Adam and Ivan. Very stupid question... TP ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman

Re: [Haskell-cafe] some questions about Template Haskell

2013-07-02 Thread TP
can also admit that the following version does not work (version of my initial post): pr :: Name - ExpQ pr n = [| putStrLn $ (nameBase n) ++ = ++ show $(varE n) |] Thanks, TP ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http

Re: [Haskell-cafe] some questions about Template Haskell

2013-07-01 Thread TP
to transform a value at data level in a token of an AST), but it seems to me it does not answer my question above. But I am probably wrong. Thanks TP ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: [Haskell-cafe] some questions about Template Haskell

2013-06-30 Thread TP
for (Lift Name) In the first argument of `nameBase', namely `n' It is not easy to surmise the reason for this error. TP ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: [Haskell-cafe] some questions about Template Haskell

2013-06-29 Thread TP
TP wrote: 2/ If I define in a module: j = 3 and then define in another module: --- h x = $([|j|]) main = do print $ h undefined --- I obtain 3 as expected. However, I do not achieve to make this system work with an infix declaration: infix

[Haskell-cafe] some questions about Template Haskell

2013-06-28 Thread TP
: --- h x = $([|j|]) main = do print $ h undefined --- I obtain 3 as expected. However, I do not achieve to make this system work with an infix declaration: infix $([| j |]) + I obtain: parse error on input `$(' What is the problem? Thanks in advance, TP

Re: [Haskell-cafe] writing a function to make a correspondance between type-level integers and value-level integers

2013-06-25 Thread TP
a condensed and easy to remember notation; still better if it is easily extended to higher dimensions/orders (unfortunately, generally these notations are not taught at university). Regards, TP o...@okmij.org wrote: Well, I guess you might be interested in geometric algebra then http

[Haskell-cafe] putting the result of a function in `infix` declaration

2013-06-23 Thread TP
at runtime. We would put some placeholders in the code where the result of the pre- processing calculation would enter. Thanks in advance, TP ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: [Haskell-cafe] writing a function to make a correspondance between type-level integers and value-level integers

2013-06-22 Thread TP
(and the corresponding article) may help me in the future. Thanks, TP ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: [Haskell-cafe] writing a function to make a correspondance between type-level integers and value-level integers

2013-06-10 Thread TP
to give a try with Haskell, monads, perhaps arrows, reactive programming, etc. Very interesting, but time-consuming. Still a long path to go for me. Thanks, TP ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman

[Haskell-cafe] writing a function to make a correspondance between type-level integers and value-level integers

2013-06-09 Thread TP
one print $ mkSNat (P one) -- Thanks, TP References: --- [1]: https://groups.google.com/forum/?fromgroups#!topic/haskell-cafe/mGDhPqHZAz8 [2]: https://groups.google.com/d/msg/haskell-cafe/Rh65kdPkX70/T2zZpV6ZpjoJ

Re: [Haskell-cafe] writing a function to make a correspondance between type-level integers and value-level integers

2013-06-09 Thread TP
be another type of kind Nat different from `'Succ n` and `Zero`? If yes, is it related to the sentence I have already read: Typeclasses are open? Thanks, TP ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo

Re: [Haskell-cafe] Typeable typeclass and type-level naturals

2013-06-05 Thread TP
a = P deriving (Typeable, Show, Eq) deriving instance Show Box instance Eq Box where (Box s1) == (Box s2) = Just s1 == cast s2 main = do let one = undefined :: Main.Proxy ('Succ 'Zero) let foo = Box one print foo -- Thanks a lot, TP

Re: [Haskell-cafe] Typeable typeclass and type-level naturals

2013-06-04 Thread TP
had unwanted similar error messages recently: http://hackage.haskell.org/trac/ghc/ticket/7704 Thanks, TP PS: the complete program for a test that shows the error: -- {-# LANGUAGE GADTs #-} {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE PolyKinds

Re: [Haskell-cafe] question about singletons

2013-06-02 Thread TP
, but I would be highly suspicious of code that used this feature.) Interesting, I will remember that. Thanks TP ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

[Haskell-cafe] Typeable typeclass and type-level naturals

2013-06-02 Thread TP
because recent improvements in Typeable are not present (1). What is the problem? I've tried different things without success. Tell me if the beginners diffusion list is more suitable than Haskell- Cafe. Thanks, TP (1): http://hauptwerk.blogspot.fr/2012/11/coming-soon-in-ghc-head-poly

Re: [Haskell-cafe] question about singletons

2013-06-01 Thread TP
inhabitants, isn't it? I hope this helps! I do have to say I'm impressed, TP, by your intrepid path of discovery down this road. You're asking all the right questions! Thanks Richard. I am discovering things in Haskell every day. In the last weeks, I have especially been amazed by all

[Haskell-cafe] question about singletons

2013-05-31 Thread TP
: --- test_noinhabitant_corrected.hs: Void showsPrec --- Why? Thanks, TP References: -- (1): https://groups.google.com/forum/?fromgroups#!topic/haskell-cafe/AltmX5iCFi8 (2): --- Expected a type, but ‛Succ Zero’ has kind

Re: [Haskell-cafe] GADT and instance deriving

2013-05-26 Thread TP
see how to combine this idea of overloading or derivation function with what you proposed. But I have perhaps missed something. Thanks, TP (*): That is to say the list of tensors of which one tensor depends, e.g. [t,r] for E(t,r), or simply [x,y,z] for f(x(t),y(t),z(t)) where x, y, and z

Re: [Haskell-cafe] GADT and instance deriving

2013-05-25 Thread TP
TP wrote: Where are these examples that can help me to write my instance? I have tried to read the source of the implemented instances in data.typeable, not so easy for me. Ok, by doing a better search on Google (instance typeable blog), I have found interesting information: http://blog

Re: [Haskell-cafe] GADT and instance deriving

2013-05-25 Thread TP
the order in the type seems to be correct. My only need to use Typeable comes from the heterogeneous list. But how to do without? Thanks, TP Richard Eisenberg wrote: Thankfully, the problem you have is fixed in HEAD -- the most recent version of GHC that we are actively working on. I am able

[Haskell-cafe] GADT and instance deriving

2013-05-24 Thread TP
$ a == a -- Is this the right way to go? Is there any other solution? Thanks, TP ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: [Haskell-cafe] GADT and instance deriving

2013-05-24 Thread TP
. But there are plenty of examples for how to do it safely. Where are these examples that can help me to write my instance? I have tried to read the source of the implemented instances in data.typeable, not so easy for me. Thanks, TP ___ Haskell-Cafe

Re: [Haskell-cafe] question about type constructors

2013-05-23 Thread TP
). The problem is that I am compelled to repeat the context (PrettyPrint (Person a), PrettyPrint (Person b)) for each one of the constructors. Is there any way to specify the context only once? I have tried using forall, but without any success. Thanks, TP - {-# LANGUAGE GADTs

[Haskell-cafe] accessing a type variable in instance declaration

2013-05-22 Thread TP
” ++ (show (c2num order)) Thanks in advance, TP ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: [Haskell-cafe] accessing a type variable in instance declaration

2013-05-22 Thread TP
, TP ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

[Haskell-cafe] question about type constructors

2013-05-22 Thread TP
signature of Child, we have a more general (Person a) - (Person b). So he tries to find an implementation of prettify in PrettyPrint (Person a), but there is none. Is there any workaround? Thanks, TP ___ Haskell-Cafe mailing list Haskell-Cafe

Re: [Haskell-cafe] question about GADT and deriving automatically a Show instance

2013-05-18 Thread TP
a } - forall (b :: Gender). Person b deriving instance Show (forall (a :: Gender). Person a) main = do let a = Alive Joe 60 Dead :: Person Female let b = Alive Jim 70 a :: Person Male Thanks, TP ___ Haskell-Cafe mailing list

Re: [Haskell-cafe] question about GADT and deriving automatically a Show instance

2013-05-18 Thread TP
:: String , weight :: Float , father :: Person b } - Person a deriving instance Show (Person a) Thanks so much, it is now perfectly clear. A lot of things learned with this dummy example. TP ___ Haskell-Cafe mailing list

Re: [Haskell-cafe] partially applied data constructor and corresponding type

2013-05-18 Thread TP
Richard Eisenberg wrote: There's a lot of recent work on GHC that might be helpful to you. Is it possible for your application to use GHC 7.6.x? If so, you could so something like this: {-# LANGUAGE DataKinds, GADTs, KindSignatures #-} data Nat = Zero | Succ Nat type One = Succ Zero

[Haskell-cafe] question about GADT and deriving automatically a Show instance

2013-05-17 Thread TP
this is because there is an infinite loop in the construction of the show function)? Is there any workaround? Thanks, TP ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: [Haskell-cafe] question about GADT and deriving automatically a Show instance

2013-05-17 Thread TP
b = Alive Jim 70 a :: Person Male print a print b How to modify it? Thanks a lot, TP ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: [Haskell-cafe] partially applied data constructor and corresponding type

2013-04-29 Thread TP
to my needs. Thanks a lot, TP On Sunday, April 28, 2013 07:58:58 Stephen Tetley wrote: What you probably want are type level integers (naturals) Yury Sulsky used them in the message above - basically you can't use literal numbers 1,2,3,... etc as they are values of type Int (or Integer

Re: [Haskell-cafe] partially applied data constructor and corresponding type

2013-04-29 Thread TP
, TP On Monday, April 29, 2013 08:19:43 Richard Eisenberg wrote: There's a lot of recent work on GHC that might be helpful to you. Is it possible for your application to use GHC 7.6.x? If so, you could so something like this: {-# LANGUAGE DataKinds, GADTs, KindSignatures #-} data Nat

[Haskell-cafe] partially applied data constructor and corresponding type

2013-04-27 Thread TP
-language: data Vector = TensorVar 1 String Because a vector is a tensor of order 1. Is this possible? I have tried type synonyms and newtypes without any success. Thanks a lot, TP ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http

Re: [Haskell-cafe] partially applied data constructor and corresponding type

2013-04-27 Thread TP
duplicating code, by reusing the tensor type and data constructor. At some place in my code, in some definition (say, of a vector product), I want vectors and not more general tensors. TP On Saturday, April 27, 2013 16:16:49 Yury Sulsky wrote: Hi TP, Are you looking to use a phantom types here? Here's

[Haskell-cafe] phantom types

2012-08-17 Thread TP
Hi, I am currently reading documentation on Generalized Algebraic Data Types: http://en.wikibooks.org/wiki/Haskell/GADT I have a question concerning this page. Let us consider the following code proposed in the page: -- -- Phantom type variable a (does not

Re: [Haskell-cafe] phantom types

2012-08-17 Thread TP
for «a» in «Expr a» input type of eval. These multiplicity of values for «a» cannot match the output type of the equation «eval (I n) = n» which is an Int. Thus we get an error. Am I correct? Thanks, TP ___ Haskell-Cafe mailing list Haskell-Cafe

[Haskell-cafe] desactivate my Show instance implementations temporarily

2012-04-22 Thread TP
to comment all the Show instances of my code, and add Show in deriving (...) for each of my types? If this is the only possibility, is there some script around here to do that automatically? Thanks in advance, TP ___ Haskell-Cafe mailing list Haskell-Cafe

Re: [Haskell-cafe] desactivate my Show instance implementations temporarily

2012-04-22 Thread TP
several lines as in classical Computer Algebra Sytems). Why not using my own Show implementation to do that? TP ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

[Haskell-cafe] using FlexibleInstances and OverlappingInstances

2012-04-07 Thread TP
instance [overlap ok] Show [Foo] -- Defined at test_overlappinginstances.hs:5:10-19 The overlap is ok (overlap ok does not appear if not using the pragma OverlappingInstances), so it should work? Thanks in advance, TP

Re: [Haskell-cafe] using FlexibleInstances and OverlappingInstances

2012-04-07 Thread TP
don't see why it could not work. Thanks TP ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

[Haskell-cafe] get a string representation (show) of a function argument

2012-03-31 Thread TP
Hi, I don't known the advanced features and extensions of GHC at all. Look at the following program: f :: Integer - Integer - IO Integer f a b = do print $ first argument= ++ (show a) print $ second argument= ++ (show b) print $ a+b return (a+b) main = do k

[Haskell-cafe] adding the elements of two lists

2012-03-25 Thread TP
to do that? I have tried: --- instance Num ListOfInt where l1 + l2 = ListOfInt $ getZipList $ (+) $ ZipList (getList l1) * ZipList (getList l2) --- Isn't it too much complicated? Thanks TP

[Haskell-cafe] parse error in pattern, and byte code interpreter

2012-01-14 Thread TP
with ocamlrun is that the process of generating the bytecode is very fast, so it is very convenient to test the program being written, in an efficient workflow. Only at the end the program is compiled to get more execution speed. Thanks a lot in advance. TP PS: --- To test the OCaml tutorial, type