[Haskell-beginners] mayBe stuck

Brent Yorgey byorgey at seas.upenn.edu
Fri Aug 6 02:57:17 EDT 2010


On Thu, Aug 05, 2010 at 06:20:06PM -0500, aditya siram wrote:
> Normally yes, but here we are guaranteed to get a 'Just ...' value because
> of the 'isNothing' guard.
> -deech

You are correct, but that's not the point.  Every time you use
fromJust (or head, or unsafePerformIO...) you shift the burden of
proving that it is safe from the compiler onto yourself.  It's like
going to a fancy restaurant and insisting on going into the kitchen
and cooking your own meal.

-Brent

> 
> On Thu, Aug 5, 2010 at 5:47 PM, Brent Yorgey <byorgey at seas.upenn.edu> wrote:
> 
> > On Thu, Aug 05, 2010 at 05:42:40PM -0500, aditya siram wrote:
> > >
> > > brS :: Maybe Int -> String -> String
> > > brS i ss
> > >    | isNothing i   = ss
> > >    | otherwise     = (take (fromJust i) ss) ++ (brS newIndex newStr)
> > >                        where
> > >                            newIndex    = findIndex eqD newStr
> > >                            newStr      = drop ((fromJust i) +1) ss
> >
> > /me makes deech write on the blackboard 100 times, "I will not use
> > fromJust"
> > _______________________________________________
> > Beginners mailing list
> > Beginners at haskell.org
> > http://www.haskell.org/mailman/listinfo/beginners
> >


More information about the Beginners mailing list