[Haskell-cafe] Synthetic values?

2011-02-09 Thread Cristiano Paris
Hi all, I've a type problem that I cannot solve and, before I keep banging my head against an unbreakable wall, I'd like to discuss it with the list. Consider the following code: module Main where class PRead p where {} class PWrite p where {} newtype Sealed p a = Sealed a

Re: [Haskell-cafe] Synthetic values?

2011-02-09 Thread Steffen Schuldenzucker
In ghci I get let evil = appendLog Foo Bar interactive:1:11: Ambiguous type variable `p' in the constraints: `PRead p' arising from a use of `appendLog' at interactive:1:11-31 `PWrite p' arising from a use of `appendLog' at interactive:1:11-31 Probable fix:

Re: [Haskell-cafe] Synthetic values?

2011-02-09 Thread Cristiano Paris
On Wed, Feb 9, 2011 at 18:43, Steffen Schuldenzucker sschuldenzuc...@uni-bonn.de wrote: ... let good = appendLog Foo Bar :: Sealed Admin String unseal (undefined :: Admin) good FooBar That's true, but putting apart the problem I posed, in my construction I wouldn't expose unseal directly nor

Re: [Haskell-cafe] Synthetic values?

2011-02-09 Thread Chris Smith
On Wed, 2011-02-09 at 18:15 +0100, Cristiano Paris wrote: I've a type problem that I cannot solve and, before I keep banging my head against an unbreakable wall, I'd like to discuss it with the list. If I'm understanding your high-level goals correctly, then you're going about things the wrong

Re: [Haskell-cafe] Synthetic values?

2011-02-09 Thread Alexey Khudyakov
On 09.02.2011 20:57, Chris Smith wrote: On Wed, 2011-02-09 at 18:15 +0100, Cristiano Paris wrote: I've a type problem that I cannot solve and, before I keep banging my head against an unbreakable wall, I'd like to discuss it with the list. If I'm understanding your high-level goals correctly,

Re: [Haskell-cafe] Synthetic values?

2011-02-09 Thread Alexey Khudyakov
On 09.02.2011 20:15, Cristiano Paris wrote: Now the problem. I would like to enforce permissions not at the role level, but at the permissions level. Let's say that I want to leave unseal unchanged, I'd like to construct a p-value for unseal combining functions checking for single permissions,

Re: [Haskell-cafe] Synthetic values?

2011-02-09 Thread Cristiano Paris
On Wed, Feb 9, 2011 at 19:33, Alexey Khudyakov alexey.sklad...@gmail.com wrote: ... If Private is not exported one cannot add instances to PRead. Nice trick. I would have thought of hiding the classes PRead and PWrite but I'm not sure if it could break the code. Thank you! -- Cristiano GPG

Re: [Haskell-cafe] Synthetic values?

2011-02-09 Thread Cristiano Paris
On Wed, Feb 9, 2011 at 20:14, Alexey Khudyakov alexey.sklad...@gmail.com wrote: ... My solution is based on heterogenous lists and require number of language extensions. I'd recomend to read paper Strongly typed heterogeneous collections[1] which describe this technique in detail Curious: I

Re: [Haskell-cafe] Synthetic values?

2011-02-09 Thread Cristiano Paris
On Wed, Feb 9, 2011 at 20:14, Alexey Khudyakov alexey.sklad...@gmail.com wrote: ... instance            PRead (WRead ::: b) instance PRead b = PRead (a ::: b) instance             PWrite (WWrite ::: b) instance PWrite b = PWrite (a ::: b) Brilliant! I was thinking to something like this but

Re: [Haskell-cafe] Synthetic values?

2011-02-09 Thread Alexey Khudyakov
On 09.02.2011 23:16, Cristiano Paris wrote: On Wed, Feb 9, 2011 at 19:33, Alexey Khudyakov alexey.sklad...@gmail.com wrote: ... If Private is not exported one cannot add instances to PRead. Nice trick. I would have thought of hiding the classes PRead and PWrite but I'm not sure if it could

Re: [Haskell-cafe] Synthetic values?

2011-02-09 Thread Bas van Dijk
On 9 February 2011 19:33, Alexey Khudyakov alexey.sklad...@gmail.com wrote: On 09.02.2011 20:57, Chris Smith wrote: On Wed, 2011-02-09 at 18:15 +0100, Cristiano Paris wrote: I've a type problem that I cannot solve and, before I keep banging my head against an unbreakable wall, I'd like to