Re: getWorkingDirectory/changeWorkingDirectory

2013-12-04 Thread Christopher Done
How does it differ to getCurrentDirectory/setCurrentDirectory in
System.Directory?


On 4 December 2013 14:38, Benjamin Franksen <
benjamin.frank...@helmholtz-berlin.de> wrote:

> Module System.Posix.Directory of the unix package defines
>
>   getWorkingDirectory :: IO FilePath
>   changeWorkingDirectory :: FilePath -> IO ()
>
> I believe the functionality is quite portable and not limited to unix-like
> systems. I know that e.g. Windows has chdir and getcwd. Module Filesystem
> of
> the system-fileio package has
>
>   getWorkingDirectory :: IO FilePath
>   setWorkingDirectory :: FilePath -> IO ()
>
> I propose to add these functions to System.Environmant or maybe
> System.Directory.
>
> Rationale:
>
> (1) This is standard functionality that should at least be in the Haskell
> Platform, if not in the standard libraries.
>
> (2) I would like to avoid depending on an extra package just to have these
> two very basic functions available in a OS independent way.
>
> (3) "system-fileio".Filesystem does not seem to be the right place for
> this.
>
> The last point may be arguable, but the first two are plain common sense
> IMO.
>
> Cheers
> Ben
> --
> "Make it so they have to reboot after every typo." ? Scott Adams
>
>
> ___
> Haskell-prime mailing list
> Haskell-prime@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-prime
>
___
Haskell-prime mailing list
Haskell-prime@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-prime


Re: Anonymous records. A solution to the problems of record-system.

2013-10-14 Thread Christopher Done
So basically, TRex?

On 14 October 2013 18:13, Nikita Volkov  wrote:
> Anonymous records. A solution to the problems of record-system.
>
> The current record system is notorious for three major flaws:
>
> It does not solve the namespacing problem. I.e., you cannot have two records
> sharing field names in a single module. E.g., the following won't compile:
>
> data A = A { field :: String }
> data B = B { field :: String }
>
> It's partial. The following code will result in a runtime error:
>
> data A = A1 { field1 :: String } | A2 { field2 :: String }
>
> main = print $ field1 $ A2 "abc"
>
> It does not allow you to use the same field name for different types across
> constructors:
>
> data A = A1 { field :: String } | A2 { field :: Int }
>
> This proposal approaches all the problems above and also a fourth one, which
> is unrelated to the current record system: it allows one to avoid
> declaration of intermediate types (see details below).
>
> Gentlemen, I want you to meet,
>
> Anonymous Records
>
> When a record-syntax is used in Haskell it's almost always a
> single-constructor ADT. A question rises then: why use ADT when you don't
> need its main feature (i.e., the multiple constructors)? This main feature
> is actually the root of the second and the third problem of record-syntax
> from the list above. In such situations one doesn't actually need ADT, but
> something more like a tuple with ability to access its items by name. E.g.:
>
> f :: (a :: Int, b :: String) -> String
> f rec = rec.b ++ show rec.a
>
> application:
>
> f (a = 123, b = "abc")
>
> So now you think "Okay, but how about naming it?". Well, not a problem at
> all - use the existingtype-construct:
>
> type TheRecord = (a :: Int, b :: String)
>
> Now, about the avoidance of intermediate types:
>
> type Person = (name :: String, phone :: (country :: Int, area :: Int, number
> :: Int))
>
> See? No need to declare separate types for inner values. But, of course, if
> you need, you still can:
>
> type Phone = (country :: Int, area :: Int, number :: Int)
> type Person = (name :: String, phone :: Phone)
>
> We can nicely access the deeply nested fields, e.g.:
>
> personCountryCode :: Person -> Int
> personCountryCode person = person.phone.country
>
> Okay. What about the type ambiguity? E.g., in the following the Person is
> actually the same type asCompany:
>
> type Person = (name :: String, phone :: Phone)
> type Company = (name :: String, phone :: Phone)
>
> Easily solvable with a help of newtype:
>
> newtype Person = Person (name :: String, phone :: Phone)
> newtype Company = Company (name :: String, phone :: Phone)
>
> What about ADTs? Again, easy:
>
> data Product = Tea (brand :: Company)
>  | Milk (brand :: Company, fatness :: Float)
>
> Now, the beautiful fact:
>
> This solution does not conflict with any existing feature of Haskell! As the
> examples show, it easily fits into the language as an extension. It can
> peacefully coexist with the existing record system of ADTs. Hence a complete
> backwards compatibility with old codebase. There's also a potential for many
> other additional features.
>
> Links
>
> Source of this proposal.
>
>
> ___
> Haskell-prime mailing list
> Haskell-prime@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-prime
>
___
Haskell-prime mailing list
Haskell-prime@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-prime


Re: String != [Char]

2012-03-17 Thread Christopher Done
On 17 March 2012 05:30, Tony Morris  wrote:
> Do you know if there is a good write-up of the benefits of Data.Text
> over String? I'm aware of the advantages just by my own usage; hoping
> someone has documented it rather than in our heads.

Good point, it would be good to collate the experience and wisdom of
this decision with some benchmark results on the HaskellWiki as The
Place to link to when justifying it.

___
Haskell-prime mailing list
Haskell-prime@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-prime


Re: TypeSynonymInstances should be enabled by default

2011-04-21 Thread Christopher Done
On 20 April 2011 21:38, Andrew Pennebaker wrote:

> The fix is easy to discover and apply, but this is my first typeclass,
> nothing complicated. As a newbie I prefer that it "just works" without my
> having to use the special compile flag.
>

Related:
http://hackage.haskell.org/trac/haskell-prime/wiki/TypeSynonymInstances
___
Haskell-prime mailing list
Haskell-prime@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-prime