[Haskell-cafe] Proposal: Non-recursive let

Andreas Abel andreas.abel at ifi.lmu.de
Fri Aug 2 16:28:04 CEST 2013


On 26.07.13 6:44 PM, Andreas Abel wrote:
>     headers0 <- M.fromList <$> do
>       forM fields_header $ \ (n, fld) -> do
>         (n,) <$> reflect $ fld ast

Ah, I forgot one more 'do' to override the stronger binding of <$>:

           (n,) <$> do reflect $ fld ast

> Great satisfaction!  I killed all long-ranging parentheses! ;-)
>
> -- Andreas
>
>>    let headers = M.insert "_report_ranges" (format_two_tstamps rv)
>> headers0
>>    foldM write_period (rv,headers,(snd rv,snd rv)) asts
>>    return ()
>>   where
>>   write_period (rv,headers,mv) ast = do
>>    pv@(p_valid_from,p_valid_until) <- reflect $ get_trange "TRange" ast
>>    check_inside pv rv
>>    let prevailing = M.lookup "PREVAILING" ast
>>    (mv,pv) <- case prevailing of
>>      Just _  -> return (pv,pv)        -- set the major valid period
>>          -- Make sure each VAR period occurs later than the prevailing
>>          -- period. If exactly at the same time add 1 min
>>      Nothing -> case () of
>>       _ | fst mv < p_valid_from  -> return (mv,pv)
>>       _ | fst mv == p_valid_from -> return (mv,(p_valid_from + 60,
>>                           p_valid_until))
>>       _  -> gthrow . InvalidData . unwords $ [
>>                "VAR period begins before prevailing:",
>>           show ast, "; prevailing TRange", show mv]
>>    let token      = maybe (M.findWithDefault "" "VAR" ast) id prevailing
>>    let ast1 = M.insert "_token" token .
>>                 M.insert "_period_valid" (format_two_tstamps pv) .
>>                   M.unionWith (\_ x -> x) headers $ ast
>>    let title      = M.member "Title" ast
>>    let headers1 = if title then headers else
>>             M.delete "_limit_to " . M.delete "_limit_recd" $ headers
>>
>>    write_fields h ast1 fields
>>
>>    return (rv,headers1,mv)
>>
>>
>> _______________________________________________
>> Haskell-Cafe mailing list
>> Haskell-Cafe at haskell.org
>> http://www.haskell.org/mailman/listinfo/haskell-cafe
>>
>
>

-- 
Andreas Abel  <><      Du bist der geliebte Mensch.

Theoretical Computer Science, University of Munich
Oettingenstr. 67, D-80538 Munich, GERMANY

andreas.abel at ifi.lmu.de
http://www2.tcs.ifi.lmu.de/~abel/




More information about the Haskell-Cafe mailing list