fay-base 0.18.0.0 → 0.19
raw patch · 5 files changed
+111/−18 lines, 5 filesdep ~basedep ~fay
Dependency ranges changed: base, fay
Files
- CHANGELOG.md +28/−0
- README.md +9/−0
- fay-base.cabal +11/−5
- src/Debug/Trace.hs +12/−0
- src/Prelude.hs +51/−13
+ CHANGELOG.md view
@@ -0,0 +1,28 @@+## Changelog++## 0.19 (2014-01-14)++* Ord instance for Integer+* Export base versions of Maybe, Ordering, and Either instead of redefining when compiling with GHC. This helps when writing libraries targeting both Fay and GHC+* `Prelude`: Add `void`, `>=>` and `<=<`, `unless`, `forM`, `mapM`+* Add `Debug.Trace` module exporting `trace` and `traceShow`++Minor:+* Upper bound to the latest major Fay version++## 0.18.0.0 (2013-09-24)++* Fixed implementation of `>>` and `>>=` (this bug didn't affect normal usage)+* Add `fail`+* Generalize type signatures for `fromIntegral` and `fromInteger`+++## 0.17.0.0 (2013-08-27)++* The type signature of `FFI.ffi` has been generalized to `IsString s => s -> a` to support `RebindableSyntax`.+* Prelude now exports `ifThenElse` as a default for `RebindableSyntax`+++## 0.16.0.0 (2013-08-05)++* Added more Ratio functions and move them all into Data.Ratio
+ README.md view
@@ -0,0 +1,9 @@+# fay-base++[Changelog](CHANGELOG.md)++This package exports Prelude, FFI and other modules which you probably want to use with [Fay](http://www.fay-lang.org).++Anything essential for using the compiler, or modules exported by GHC's base can go in this package.++The major version number is coupled with Fay itself, so fay 0.18.* should be used with fay-base 0.18.*.
fay-base.cabal view
@@ -1,23 +1,28 @@ name: fay-base-version: 0.18.0.0+version: 0.19 synopsis: The base package for Fay. description: The base package for Fay.- This package exports Prelude and FFI which you probably want to use with Fay.+ This package amongst others exports Prelude and FFI which you probably want to use with Fay. license: BSD3 license-file: LICENSE author: Chris Done-maintainer: adam@edea.se+maintainer: adam@bergmark.nl homepage: https://github.com/faylang/fay-base bug-reports: https://github.com/faylang/fay-base/issues copyright: 2012 Chris Done-category: Development+category: Development, Fay build-type: Simple cabal-version: >=1.8+extra-source-files:+ LICENSE+ README.md+ CHANGELOG.md data-files: src/Prelude.hs src/FFI.hs src/Data/Data.hs src/Data/Ratio.hs+ src/Debug/Trace.hs source-repository head type: git@@ -30,4 +35,5 @@ ,FFI ,Data.Data ,Data.Ratio- build-depends: base == 4.*, fay >= 0.18+ ,Debug.Trace+ build-depends: base == 4.*, fay >= 0.19 && < 0.20
+ src/Debug/Trace.hs view
@@ -0,0 +1,12 @@+{-# LANGUAGE NoImplicitPrelude #-}++module Debug.Trace where++import Prelude+import FFI++trace :: String -> Ptr a -> Ptr a+trace = ffi "console.log(%1),%2"++traceShow :: Automatic a -> Ptr b -> Ptr b+traceShow = ffi "console.log(%1),%2"
src/Prelude.hs view
@@ -27,11 +27,17 @@ ,return ,fail ,when+ ,unless+ ,forM ,forM_+ ,mapM ,mapM_ ,(=<<) ,sequence ,sequence_+ ,void+ ,(>=>)+ ,(<=<) -- Num ,(*) ,(+)@@ -209,6 +215,9 @@ import "base" Prelude (Bool (True, False), Eq, seq, (&&), (/=), (==), (||)) import qualified "base" Prelude as Base+#ifndef FAY+import "base" Prelude (Either (..), Maybe (..), Ordering (..))+#endif -------------------------------------------------------------------------------- -- Fixities@@ -230,7 +239,7 @@ infixr 4 <, <=, >=, > infixl 1 >>, >>=-infixr 1 =<<+infixr 1 =<<, >=>, <=< infixr 0 $, $! -- PreludeList@@ -242,23 +251,28 @@ -------------------------------------------------------------------------------- -- Aliases of base -type String = Base.String-type Int = Base.Int-type Double = Base.Double-type Char = Base.Char+type Char = Base.Char+type Double = Base.Double+type Int = Base.Int+type Integer = Base.Integer+type String = Base.String -------------------------------------------------------------------------------- -- Standard data types -- | Maybe type.+#ifdef FAY data Maybe a = Just a | Nothing instance Base.Read a => Base.Read (Maybe a) instance Base.Show a => Base.Show (Maybe a) instance Typeable a => Typeable (Maybe a) instance Data a => Data (Maybe a)+#endif -- | Either type.+#ifdef FAY data Either a b = Left a | Right b+#endif maybe :: t -> (t1 -> t) -> Maybe t1 -> t maybe m _ Nothing = m@@ -285,10 +299,19 @@ when :: Bool -> Fay a -> Fay () when p m = if p then m >> return () else return () -forM_ :: [t] -> (t -> Fay a) -> Fay ()+unless :: Bool -> Fay a -> Fay ()+unless p m = if p then return () else m >> return ()++forM :: [a] -> (a -> Fay b) -> Fay [b]+forM lst fn = sequence $ map fn lst++forM_ :: [a] -> (a -> Fay b) -> Fay () forM_ (x:xs) m = m x >> forM_ xs m forM_ [] _ = return () +mapM :: (a -> Fay b) -> [a] -> Fay [b]+mapM fn lst = sequence $ map fn lst+ mapM_ :: (a -> Fay b) -> [a] -> Fay () mapM_ m (x:xs) = m x >> mapM_ m xs mapM_ _ [] = return ()@@ -296,6 +319,15 @@ (=<<) :: (a -> Fay b) -> Fay a -> Fay b f =<< x = x >>= f +void :: Fay a -> Fay ()+void f = f >> return ()++(>=>) :: (a -> Fay b) -> (b -> Fay c) -> a -> Fay c+(>=>) f g x = f x >>= g++(<=<) :: (b -> Fay c) -> (a -> Fay b) -> a -> Fay c+(<=<) g f x = f x >>= g+ -- | Evaluate each action in the sequence from left to right, -- and collect the results. sequence :: [Fay a] -> Fay [a]@@ -322,17 +354,20 @@ -- Ord -- An ordering.+#ifdef FAY data Ordering = GT | LT | EQ+#endif class (Eq a,Base.Ord a) => Ord a where- (<) :: a -> a -> Bool- (<=) :: a -> a -> Bool- (>) :: a -> a -> Bool- (>=) :: a -> a -> Bool+ (<) :: a -> a -> Bool+ (<=) :: a -> a -> Bool+ (>) :: a -> a -> Bool+ (>=) :: a -> a -> Bool -instance Ord Int-instance Ord Double instance Ord Char+instance Ord Double+instance Ord Int+instance Ord Integer compare :: Ord a => a -> a -> Ordering compare x y =@@ -348,6 +383,8 @@ class (Base.Enum a) => Enum a where instance Enum Int+-- Integers are represented as JS numbers which aren't arbitrary precision+-- se we shouldn't add an Enum instance. succ :: Num a => a -> a succ x = x + 1@@ -390,11 +427,12 @@ class (Enum a,Base.Integral a) => Integral a instance Integral Int+-- Can't add Integer instance since Integer isn't an Enum (see Enum above). fromIntegral :: (Num a, Num b) => Ptr a -> Ptr b fromIntegral = ffi "%1" -fromInteger :: Num a => Ptr Base.Integer -> Ptr a+fromInteger :: Num a => Ptr Integer -> Ptr a fromInteger = ffi "%1" --------------------------------------------------------------------------------