From 0c2c887de10702206ee645452a86674500314948 Mon Sep 17 00:00:00 2001 From: Alberto Ruiz Date: Mon, 27 Apr 2009 17:25:18 +0000 Subject: more defined (|>) and (><) as suggested by Tracy Wadleigh --- lib/Data/Packed/Internal/Vector.hs | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) (limited to 'lib/Data/Packed/Internal') diff --git a/lib/Data/Packed/Internal/Vector.hs b/lib/Data/Packed/Internal/Vector.hs index 0e6b3f4..fc8a6be 100644 --- a/lib/Data/Packed/Internal/Vector.hs +++ b/lib/Data/Packed/Internal/Vector.hs @@ -91,21 +91,17 @@ inlinePerformIO (IO m) = case m realWorld# of (# _, r #) -> r toList :: Storable a => Vector a -> [a] toList v = safeRead v $ peekArray (dim v) --- | an alternative to 'fromList' with explicit dimension, used also in the instances for Show (Vector a). -(|>) :: (Storable a) => Int -> [a] -> Vector a -infixl 9 |> -n |> l = if length l == n then fromList l else error "|> with wrong size" - -{- | Like '(|>)', but explicitly truncates the list, if it is too long. +{- | An alternative to 'fromList' with explicit dimension. The input + list is explicitly truncated if it is too long, so it may safely + be used, for instance, with infinite lists. -It may safely be used, for instance, with infinite lists. + This is the format used in the instances for Show (Vector a). -} -(|>|) :: (Storable a) => Int -> [a] -> Vector a -infixl 9 |>| -n |>| l = if length l' == n then - fromList l' - else - error "|>|: list too short" +(|>) :: (Storable a) => Int -> [a] -> Vector a +infixl 9 |> +n |> l = if length l' == n + then fromList l' + else error "list too short for |>" where l' = take n l -- cgit v1.2.3