Send Beginners mailing list submissions to
[email protected]
To subscribe or unsubscribe via the World Wide Web, visit
http://www.haskell.org/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
[email protected]
You can reach the person managing the list at
[email protected]
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."
Today's Topics:
1. Re: Questions on GHCi 6.10.4 + general questions (Antoine Latter)
2. Re: Questions on GHCi 6.10.4 + general questions (Stephen Tetley)
3. Re: Questions on GHCi 6.10.4 + general questions (Chadda? Fouch?)
4. Re: Questions on GHCi 6.10.4 + general questions (Stephen Tetley)
5. Re: Questions on GHCi 6.10.4 + general questions (Lev Broido)
6. Re: Questions on GHCi 6.10.4 + general questions (Stephen Tetley)
7. Re: Questions on GHCi 6.10.4 + general questions (Lev Broido)
----------------------------------------------------------------------
Message: 1
Date: Fri, 27 Nov 2009 03:06:52 -0600
From: Antoine Latter <[email protected]>
Subject: Re: [Haskell-beginners] Questions on GHCi 6.10.4 + general
questions
To: Lev Broido <[email protected]>
Cc: [email protected]
Message-ID:
<[email protected]>
Content-Type: text/plain; charset=UTF-8
On Fri, Nov 27, 2009 at 2:44 AM, Lev Broido <[email protected]> wrote:
> Hi
> I am getting the following message :
> parse error on input `=
> Code in question is attached .
>
On which line is the error occurring?
I'm not used to seeing braces used without semi-colons, so the last
bit is hard to follow.
The 'where' clause after 'new_state' appears to be at the same
indentation level as the 'new_state' declaration, which might confuse
GHC. But I'm not sure what the rules are once you start throwing the
braces around.
Antoine
------------------------------
Message: 2
Date: Fri, 27 Nov 2009 09:15:03 +0000
From: Stephen Tetley <[email protected]>
Subject: Re: [Haskell-beginners] Questions on GHCi 6.10.4 + general
questions
To: Lev Broido <[email protected]>
Cc: [email protected]
Message-ID:
<[email protected]>
Content-Type: text/plain; charset=ISO-8859-1
Hi Lev
Where clauses don't use braces so that's first problem.
Also this line near the end has a problem:
curr_bank_state = head . filter (\y -> y == (wr_bank,_) state
What should it be doing?
Best wishes
Stephen
2009/11/27 Lev Broido <[email protected]>:
> Hi
> I am getting the following message :
> parse error on input `=
> Code in question is attached .
>
> Another general question on haskell :
> I am not sure I understand correctly the 'where' clause usage , I'll
> happily accept comments on the code
>
> Thanks,
> Lev
>
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
>
>
------------------------------
Message: 3
Date: Fri, 27 Nov 2009 10:22:28 +0100
From: Chadda? Fouch? <[email protected]>
Subject: Re: [Haskell-beginners] Questions on GHCi 6.10.4 + general
questions
To: Stephen Tetley <[email protected]>
Cc: [email protected]
Message-ID:
<[email protected]>
Content-Type: text/plain; charset=UTF-8
On Fri, Nov 27, 2009 at 10:15 AM, Stephen Tetley
<[email protected]> wrote:
> Hi Lev
>
> Where clauses don't use braces so that's first problem.
You are mistaken, where clauses can use braces to avoid having to use
layout as all others layout-based constructs in Haskell (do, where,
let, case _ of, even the top-level...). But in this case the
semicolons are mandatory, since you're explicitly rejecting
layout-based rules. That is one problem of this code (use of braces
without the semicolons), I didn't check if there were others.
--
Jedaï
------------------------------
Message: 4
Date: Fri, 27 Nov 2009 09:23:14 +0000
From: Stephen Tetley <[email protected]>
Subject: Re: [Haskell-beginners] Questions on GHCi 6.10.4 + general
questions
Cc: [email protected]
Message-ID:
<[email protected]>
Content-Type: text/plain; charset=ISO-8859-1
2009/11/27 Stephen Tetley <[email protected]>:
> Where clauses don't use braces so that's first problem.
Apologies where clauses can have braces - by convention people don't use them.
Best wishes
Stephen
http://www.haskell.org/onlinereport/syntax-iso.html#sect9
------------------------------
Message: 5
Date: Fri, 27 Nov 2009 11:52:07 +0200
From: Lev Broido <[email protected]>
Subject: Re: [Haskell-beginners] Questions on GHCi 6.10.4 + general
questions
To: [email protected]
Message-ID:
<[email protected]>
Content-Type: text/plain; charset="iso-8859-1"
On Fri, Nov 27, 2009 at 11:48 AM, Lev Broido <[email protected]> wrote:
> Thanks for reply .
> I used braces , since previous error was on indentation and I wasn't sure
> what was wrong .
> The intent of the *curr_bank_state = head . filter (\y -> y ==
> (wr_bank,_) state was
> *get first entry (only entry) from list of tuples (Time,BankStateSIngle)
> matching condition Time == wr_bank .
>
> After removing braces the message is
> DdrController.hs:112:8:
> parse error (possibly incorrect indentation)
> Failed, modules loaded: none.
>
> Thanks,
> Lev
>
>
> On Fri, Nov 27, 2009 at 11:15 AM, Stephen Tetley <[email protected]
> > wrote:
>
>> Hi Lev
>>
>> Where clauses don't use braces so that's first problem.
>>
>> Also this line near the end has a problem:
>>
>> curr_bank_state = head . filter (\y -> y == (wr_bank,_) state
>>
>> What should it be doing?
>>
>> Best wishes
>>
>> Stephen
>>
>> 2009/11/27 Lev Broido <[email protected]>:
>> > Hi
>> > I am getting the following message :
>> > parse error on input `=
>> > Code in question is attached .
>> >
>> > Another general question on haskell :
>> > I am not sure I understand correctly the 'where' clause usage , I'll
>> > happily accept comments on the code
>> >
>> > Thanks,
>> > Lev
>> >
>> >
>> > _______________________________________________
>> > Beginners mailing list
>> > [email protected]
>> > http://www.haskell.org/mailman/listinfo/beginners
>> >
>> >
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://www.haskell.org/pipermail/beginners/attachments/20091127/217d4493/attachment-0001.html
------------------------------
Message: 6
Date: Fri, 27 Nov 2009 10:09:43 +0000
From: Stephen Tetley <[email protected]>
Subject: Re: [Haskell-beginners] Questions on GHCi 6.10.4 + general
questions
To: Lev Broido <[email protected]>
Cc: [email protected]
Message-ID:
<[email protected]>
Content-Type: text/plain; charset=ISO-8859-1
Hi Lev
This one compiles with fairly minimal changes
The main one is the new_state = ... line near the end has part
commented out where there would otherwise be a type error.
Also the nest where clause at the end was obscuring a variable binding
that you needed, so I've removed the nesting.
Pasted from my editor, hopefully, my mail client doesn't mangle the code:
module DdrController where
{-
- DDR controller implements top function drive of original
- list of commands . Assuming data is random .
- The first version will drive commands from original command list
- and adding to each command delta time , corresponding to minimum time
- possible to execute
-}
-- Each command has it's set of attributes
type Time = Int
data DdrCmd =
READ { bank :: Int, col :: Int } |
READ_PCH { bank :: Int, col :: Int} |
WRITE { bank :: Int, col :: Int} |
WRITE_PCH { bank :: Int, col :: Int} |
PCH_CMD {bank :: Int} |
ACTIVATE {bank :: Int,row :: Int} |
PCH_ALL |
BST
type DdrCommand = (Time,DdrCmd) -- Type of command containing offset
-- Using tree to search for bank info
data BankStateSingle = Single { bank_id :: Int , last_ras :: Time ,
last_cas :: Time , last_pch :: Time };
type BankEntry = (Int,BankStateSingle);
type BankState = [BankEntry];
-- Check point events
data TimingCheckPoint = RAS | CAS | PCH | NONE deriving Show
type TimingCondition = (Int,TimingCheckPoint,TimingCheckPoint)
-- All possible timing constraints
data (Num a,Show a) => TimingParams a = TRP a | TRCD a | TRAS a
-- Function to initialize timing params
-- Randomly generates
-- Create list of entries
init_bank_set :: [BankStateSingle] -> BankState
init_bank_set ba_list = zip [0..((length ba_list)-1)] ba_list
timing_configuration :: [(Int,TimingCheckPoint,TimingCheckPoint)]
timing_configuration = [ {-tRCD-}(4,RAS,CAS) , {-tRC-}
(10,RAS,RAS),{-tRP-} (2,PCH,RAS)]
-- Translation of timing check point
cmd2timing_checkpoint :: DdrCmd -> TimingCheckPoint
cmd2timing_checkpoint cmd = case cmd of
READ _ _ -> CAS
READ_PCH _ _ -> CAS
WRITE _ _ -> CAS
WRITE_PCH _ _-> CAS
PCH_CMD _-> PCH
ACTIVATE _ _ -> RAS
PCH_ALL -> PCH
BST -> NONE
-- Return method from bank Id to bank selector func
bank_timing_update :: Time -> TimingCheckPoint -> BankStateSingle ->
BankStateSingle
bank_timing_update time chk_point bank_state = new_bank_state
where
new_bank_state =
case chk_point of
RAS -> bank_state { last_ras = time }
CAS -> bank_state { last_cas = time }
PCH -> bank_state { last_pch = time }
-- Change entry in list with other one if condition is met
--upd_list :: (a -> Bool)->a->[a]->[a]
--upd_list = ()
-- Calculate cmd delay and update bank state
-- For each cmd define whether this is RAS,CAS or PCH command
-- For each cmd , find bank it refers to
-- For bank calculate new timing offset based on last occurrence
beginning of arc
-- and longest arc to satisfy
updateCmdDelay :: DdrCommand -> BankState -> [TimingCondition] ->
(DdrCommand,BankState)
-- There are separate cases for commands
-- PCH_ALL works on all banks and thus could not be issued before precharge
-- timing ark is met for all cases
updateCmdDelay (time,PCH_ALL) state timing = undefined
updateCmdDelay (time,BST) state timing = ((time,BST),state)
updateCmdDelay (time,(WRITE wr_bank wr_col)) state timing =
-- Get all timing arcs to 'cmd2timing_checkpoint
-- Find maximum by folding of delays and
--
((new_time,(WRITE wr_bank wr_col)),new_state)
where {
--new_state = num2bank wr_bank;
new_time = if (earliest_time > time ) then earliest_time else time;
new_state = (take ( wr_bank ) state) ++ {-
[(wr_bank,curr_bank_state)] ++ -} (drop (wr_bank + 2) state);
earliest_time = last_event_occur + (foldl max 0 delays);
delays = [ time | (time,_,endpoint) <- timing ];
last_event_occur = case endpoint of
{ RAS -> last_ras $ snd curr_bank_state ;
CAS -> last_cas $ snd curr_bank_state ;
PCH -> last_pch $ snd curr_bank_state } ;
-- Blabla
endpoint = cmd2timing_checkpoint (WRITE wr_bank wr_col);
curr_bank_state = head $ filter (\y -> fst y == wr_bank) state
-- Update one of mields : last_ras,last_cas,last_pch
-- For each bank
}
------------------------------
Message: 7
Date: Fri, 27 Nov 2009 12:20:57 +0200
From: Lev Broido <[email protected]>
Subject: Re: [Haskell-beginners] Questions on GHCi 6.10.4 + general
questions
To: Stephen Tetley <[email protected]>
Cc: [email protected]
Message-ID:
<[email protected]>
Content-Type: text/plain; charset="iso-8859-1"
Thank you very match
On Fri, Nov 27, 2009 at 12:09 PM, Stephen Tetley
<[email protected]>wrote:
> Hi Lev
>
> This one compiles with fairly minimal changes
>
> The main one is the new_state = ... line near the end has part
> commented out where there would otherwise be a type error.
>
> Also the nest where clause at the end was obscuring a variable binding
> that you needed, so I've removed the nesting.
>
> Pasted from my editor, hopefully, my mail client doesn't mangle the code:
>
> module DdrController where
> {-
> - DDR controller implements top function drive of original
> - list of commands . Assuming data is random .
> - The first version will drive commands from original command list
> - and adding to each command delta time , corresponding to minimum time
> - possible to execute
> -}
>
> -- Each command has it's set of attributes
> type Time = Int
>
>
> data DdrCmd =
> READ { bank :: Int, col :: Int } |
> READ_PCH { bank :: Int, col :: Int} |
> WRITE { bank :: Int, col :: Int} |
> WRITE_PCH { bank :: Int, col :: Int} |
> PCH_CMD {bank :: Int} |
> ACTIVATE {bank :: Int,row :: Int} |
> PCH_ALL |
> BST
>
> type DdrCommand = (Time,DdrCmd) -- Type of command containing offset
>
>
> -- Using tree to search for bank info
> data BankStateSingle = Single { bank_id :: Int , last_ras :: Time ,
> last_cas :: Time , last_pch :: Time };
>
> type BankEntry = (Int,BankStateSingle);
> type BankState = [BankEntry];
>
>
>
> -- Check point events
> data TimingCheckPoint = RAS | CAS | PCH | NONE deriving Show
>
>
>
> type TimingCondition = (Int,TimingCheckPoint,TimingCheckPoint)
> -- All possible timing constraints
> data (Num a,Show a) => TimingParams a = TRP a | TRCD a | TRAS a
>
> -- Function to initialize timing params
> -- Randomly generates
>
> -- Create list of entries
> init_bank_set :: [BankStateSingle] -> BankState
> init_bank_set ba_list = zip [0..((length ba_list)-1)] ba_list
>
> timing_configuration :: [(Int,TimingCheckPoint,TimingCheckPoint)]
> timing_configuration = [ {-tRCD-}(4,RAS,CAS) , {-tRC-}
> (10,RAS,RAS),{-tRP-} (2,PCH,RAS)]
>
>
> -- Translation of timing check point
> cmd2timing_checkpoint :: DdrCmd -> TimingCheckPoint
> cmd2timing_checkpoint cmd = case cmd of
> READ _ _ -> CAS
> READ_PCH _ _ -> CAS
> WRITE _ _ -> CAS
> WRITE_PCH _ _-> CAS
> PCH_CMD _-> PCH
> ACTIVATE _ _ -> RAS
> PCH_ALL -> PCH
> BST -> NONE
>
> -- Return method from bank Id to bank selector func
>
> bank_timing_update :: Time -> TimingCheckPoint -> BankStateSingle ->
> BankStateSingle
> bank_timing_update time chk_point bank_state = new_bank_state
> where
> new_bank_state =
> case chk_point of
> RAS -> bank_state { last_ras = time }
> CAS -> bank_state { last_cas = time }
> PCH -> bank_state { last_pch = time }
>
>
> -- Change entry in list with other one if condition is met
> --upd_list :: (a -> Bool)->a->[a]->[a]
> --upd_list = ()
>
> -- Calculate cmd delay and update bank state
> -- For each cmd define whether this is RAS,CAS or PCH command
> -- For each cmd , find bank it refers to
> -- For bank calculate new timing offset based on last occurrence
> beginning of arc
> -- and longest arc to satisfy
>
> updateCmdDelay :: DdrCommand -> BankState -> [TimingCondition] ->
> (DdrCommand,BankState)
> -- There are separate cases for commands
> -- PCH_ALL works on all banks and thus could not be issued before
> precharge
> -- timing ark is met for all cases
> updateCmdDelay (time,PCH_ALL) state timing = undefined
> updateCmdDelay (time,BST) state timing = ((time,BST),state)
>
> updateCmdDelay (time,(WRITE wr_bank wr_col)) state timing =
>
> -- Get all timing arcs to 'cmd2timing_checkpoint
>
> -- Find maximum by folding of delays and
>
> --
>
> ((new_time,(WRITE wr_bank wr_col)),new_state)
>
> where {
> --new_state = num2bank wr_bank;
>
> new_time = if (earliest_time > time ) then earliest_time else time;
>
>
> new_state = (take ( wr_bank ) state) ++ {-
> [(wr_bank,curr_bank_state)] ++ -} (drop (wr_bank + 2) state);
>
> earliest_time = last_event_occur + (foldl max 0 delays);
>
> delays = [ time | (time,_,endpoint) <- timing ];
>
> last_event_occur = case endpoint of
> { RAS -> last_ras $ snd curr_bank_state ;
> CAS -> last_cas $ snd curr_bank_state ;
> PCH -> last_pch $ snd curr_bank_state } ;
>
> -- Blabla
> endpoint = cmd2timing_checkpoint (WRITE wr_bank wr_col);
>
>
> curr_bank_state = head $ filter (\y -> fst y == wr_bank) state
>
> -- Update one of mields : last_ras,last_cas,last_pch
> -- For each bank
>
>
> }
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://www.haskell.org/pipermail/beginners/attachments/20091127/d2366688/attachment.html
------------------------------
_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
End of Beginners Digest, Vol 17, Issue 31
*****************************************