#apache #archlinux #asterisk #centos #debian #gentoo #haskell #kde #kubuntu #lisp #math #mysql #perl #python #ruby-lang #rubyonrails #suse #ubuntu #vim #wikipedia 0 1 2 3 4 5 6 7 8 9 10 11 12
Top Prev 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 Next
#haskell
<Cale> Left "You can't do that sillypants!"
<Cale> Right 5
<Cale> But sure, if you want to catch it in IO, you use catch with evaluate like that.
<Eighty> cale: yeah, i know, but i'd rather not clutter down every single function to return a datatype like that
<Cale> Note that you have to apply evaluate to *the specific value* you want to check for undefined.
<Cheery> I think I like this thing.
<kaol> is Left always error?
<Cale> kaol: by convention, when one of them is an error, yes
<Eighty> Cale: what do you mean by "the specific value"?
<nmessenger> kaol: it's fail in its Monad instance
<Cheery> I can represent my state machine as simple transition rules to another statemachines.
<Cale> Eighty: If you apply it to a list, for instance, it won't catch errors in the elements.
<Cheery> S1 = [Transition C1 S2]
<Saizan> and it's also how (Error e) => MonadError (Either e) is defined
<Cale> nmessenger: sssh, we pretend that fail doesn't exist around here :)
<nmessenger> heh
<Eighty> Cale: hm, doesn't [undefined] reduce to undefined?
<Cale> Eighty: no, it's a different value
<allbery_b> only if something looks inside the list
<xerox> > length [undefined]
<Cale> > length [undefined]
<lambdabot> 1
<Cale> haha
<xerox> ;)
<Cale> > length undefined
<lambdabot> Undefined
<Eighty> yeah, but when the program looks at the undefined value
<Cheery> > length [undefined, undefined]
<lambdabot> 2
<xerox> > head [undefined]
<Cale> [undefined] = (:) undefined []
<lambdabot> Undefined
<allbery_b> if your program evaluator is script, then sure
<nmessenger> @src length
<lambdabot> Source not found. Wrong! You cheating scum!
<allbery_b> er, is strict
<Cale> You can do: foldr seq () xs
<Cale> to force lists with undefined values in them to be undefined
<Eighty> okay
<Cheery> thought with such S1 = [Transition C1 S2] I don't do much. :/
<Cale> > length (foldr seq xs xs)
<lambdabot> Not in scope: `xs'
<Cale> > let strictList xs = foldr seq xs xs in length (strictList [undefined])
<nmessenger> > foldr seq () [1..5]
<lambdabot> Undefined
<lambdabot> ()
<benja_> note however, that if 'xs' evaluates to 'Not in scope: `xs'', then so does '[xs]' ;)
<Cale> benja_: hehe
<dancor> strict scoping
<Cale> Of course, it doesn't *evaluate* to that :)
Previous Page Next Page