On Thu, Nov 03, 2005 at 08:35:26PM -0800, Andrew Pimlott wrote:
> I want a function
>
> > newtype Empty = Empty (forall a. [a])
> > listToEmpty :: [v] -> IO Empty
> > listToEmpty l = liftM Empty (mapM no l) where
> > no :: a -> IO a'
> > no x = fail "element found"
...
> I could probably defin
On Thu, Nov 03, 2005 at 11:57:49PM -0800, Ralf Lammel wrote:
> Let's do an experiment.
> We replace the IO monad by the Id(entity) monad.
> We actually replace the Id newtype also to become true type-level
> identity.
> So we get:
>
> --
> -- This is like your 2nd say unchecked... sample
> --
>
>
| But this gives a "less polymorphic" error. I think the problem is
that
| ghc will not instantiate the "a'" in "IO a'" as a higher-rank type
| because it occurs within a type contructor. I believe this is the
| restriction referred to at the end of 7.4.9[1]. If I instead write
I think that is
roach is to use consistently rank-2 combinators.
I probably don't get what you try to do.
Ralf
> -Original Message-
> From: [EMAIL PROTECTED] [mailto:haskell-cafe-
> [EMAIL PROTECTED] On Behalf Of Andrew Pimlott
> Sent: Thursday, November 03, 2005 8:35 PM
> To: haskell-cafe@haskell.o
I am trying to use a rank 2 type to enforce a condition on a data
structure. For the purpose of this message, I am trying to ensure that
a list is empty (ignoring the possibility of bottom elements):
> {-# OPTIONS -fglasgow-exts #-}
> import Control.Monad
> newtype Empty = Empty (forall a. [a])